laoo Posted June 28, 2023 Share Posted June 28, 2023 7 hours ago, 42bs said: Right 🙂 https://www.pouet.net/prod.php?which=94428 That shit is intense 😵 1 Quote Link to comment Share on other sites More sharing options...
Seedy1812 Posted June 28, 2023 Share Posted June 28, 2023 To convert RGB to CRY is a simple process but needs a bit of brute force. In the Tech Ref manual is a table for the CRY palette split into the (YUV_)R , (YUV_)G and (YUV_)B values. So if we go Cry(index:8 , intensity:8 ) to RGB then R = (YUV_R[index] * intensity) / 256 G = (YUV_G[index] * intensity) / 256 B = (YUV_B[index] * intensity) / 256 So to go RGB to CRY we need to find the colour with the least error So go through all intensities 0 to 255 and use a bit of Pythagoras deltaR = rgbR - R(index,intensity) lengthR = SQRT(deltaR * deltaR) deltaG = rgbG - G(index,intensity) lengthG = SQRT(deltaG * deltaG) deltaB = rgbB - B(index,intensity) lengthB = SQRT(deltaB * deltaB) length = lengthR * LengthG * LengthB; At the smallest length then the cry value is index:intensity Quote Link to comment Share on other sites More sharing options...
laoo Posted June 28, 2023 Share Posted June 28, 2023 (edited) In the Tech Ref manual there is also an explanation that CRY is designed in such a way that no brute force is really needed and it can be converted in constant time. The intensity is just I = max(R,G,B), then R2 = R * 255 / I, G2 = G * 255 / I, B2 = B * 255 / I. Now we just need 3 2D 256x256 tables with color component of CRY: [R2,G2], [R2,B2], [G2,B2] and we are using one table that is indexed by other two components than the max one. Edited June 28, 2023 by laoo Quote Link to comment Share on other sites More sharing options...
Zerosquare Posted June 28, 2023 Share Posted June 28, 2023 (edited) 4 hours ago, Seedy1812 said: To convert RGB to CRY is a simple process but needs a bit of brute force. (...) At the smallest length then the cry value is index:intensity 3 hours ago, laoo said: In the Tech Ref manual there is also an explanation that CRY is designed in such a way that no brute force is really needed and it can be converted in constant time. The intensity is just I = max(R,G,B), then R2 = R * 255 / I, G2 = G * 255 / I, B2 = B * 255 / I. Now we just need 3 2D 256x256 tables with color component of CRY: [R2,G2], [R2,B2], [G2,B2] and we are using one table that is indexed by other two components than the max one. Yes, that's what I do in my converter. The thing is, in theory, you shouldn't have to use brute force to create the lookup tables ; you should be able to compute the CRY value directly using a mathematical formula. But in practice, it doesn't work quite right. Edited June 28, 2023 by Zerosquare Quote Link to comment Share on other sites More sharing options...
Seedy1812 Posted June 28, 2023 Share Posted June 28, 2023 (edited) 1 hour ago, Zerosquare said: Yes, that's what I do in my converter. The thing is, in theory, you shouldn't have to use brute force to create the lookup tables ; you should be able to compute the CRY value directly using a mathematical formula. But in practice, it doesn't work quite right. From the 16 million RGB colours you have to map this down to 65536 CRY colours . As the intensity decreases the perceived number of colours reduce. ( The darker the colour the more they look the same ). For most colours there is no RGB to CRY match so you have to find the nearest one. You are only finding the the output CRY value . The Cry lookup tables are constant so there is they do not have to be calculated. Edited June 28, 2023 by Seedy1812 Quote Link to comment Share on other sites More sharing options...
42bs Posted June 28, 2023 Share Posted June 28, 2023 So, we need a painting program with CRY mode 🙂 Maybe this can be enhanced: https://github.com/mriale/PyDPainter 1 Quote Link to comment Share on other sites More sharing options...
laoo Posted March 7 Share Posted March 7 As a side-effect of my tooling efforts I've created an image that shows where are CRY colors with intensity 255 on three RGB planes. Left-bottom are all colors with R=255, left-upper have blue=255 and right-top have green=255. Black points are in place of colors representable using CRY. I decided to share it because it's interesting to know which areas are more densly populated by CRY colors and which on the contrary and besides it looks cool 4 Quote Link to comment Share on other sites More sharing options...
laoo Posted March 7 Share Posted March 7 (edited) Strangely can't edit my post and just wanted to add another diagram with Voronoi cells for each CRY color. These are actually three separate images combined in one, so there are separate cells on the edges of squares. Edited March 7 by laoo 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.