So... One of the things I'm implementing in Sonic Triad's Palette Editor is the ability to convert RGB to YUV. Basically, I want to be able to apply this type of effect on palettes... seen in this image taken from wikipedia.org: The black and white one is its Y component... which is a variation of greyscaling. The blue/green is its U component. The last is the V component. Now, I've got equations that I've been told should do the trick... Now, I believe the first is working as it should be, as RGB are set to the value. But I am applying the equations for U and V to all three RGB values as well... and I know that's why the color doesn't come across correctly, but I don't know how to configure the values to the colors correctly. Here is my code from Triad's open source for all 3 YUV functions. PLEASE NOTE that this is all in GML, as Triad is written using Game Maker. Code (Text): // Y - Equations based on what I found on www.fourcc.org/fccyvrgb.php if (yuvmode==1) {for(I=c1;I!=c2;I+=c3) { m[I,a]=((color_get_red(pcol[I,a])*0.299)+(color_get_green(pcol[I,a])*0.587)+(color_get_blue(pcol[I,a])*0.114)); // Weighted Average of the 3 color components for each color. c[I,a]=round(m[I,a]/34)*34; // The colors are made Gens compatible, as colors are multiples of 34. ($22) // Get our final color code, in format 0BGR pal[I,a]="0"+string_char_at(dec_to_hex(c[I,a]),2) +string_char_at(dec_to_hex(c[I,a]),2) +string_char_at(dec_to_hex(c[I,a]),2); pcol[I,a]=draw_hex_color(pal[I,a]); // Set drawing color for palette box. }} // U if (yuvmode==2) {for(I=c1;I!=c2;I+=c3) { m[I,a]=((color_get_red(pcol[I,a])*0.147)-(color_get_green(pcol[I,a])*0.289)-(color_get_blue(pcol[I,a])*0.436)+128); // Weighted Average of the 3 color components for each color. c[I,a]=round(m[I,a]/34)*34; // The colors are made Gens compatible, as colors are multiples of 34. ($22) // Get our final color. pal[I,a]="0"+string_char_at(dec_to_hex(c[I,a]),2) +string_char_at(dec_to_hex(c[I,a]),2) +string_char_at(dec_to_hex(c[I,a]),2); pcol[I,a]=draw_hex_color(pal[I,a]); // Set drawing color for palette box. }} // V if (yuvmode==3) {for(I=c1;I!=c2;I+=c3) { m[I,a]=((color_get_red(pcol[I,a])*0.615)-(color_get_green(pcol[I,a])*0.515)-(color_get_blue(pcol[I,a])*0.1)+128); // Weighted Average of the 3 color components for each color. c[I,a]=round(m[I,a]/34)*34; // The colors are made Gens compatible, as colors are multiples of 34. ($22) // Get our final color. pal[I,a]="0"+string_char_at(dec_to_hex(c[I,a]),2) +string_char_at(dec_to_hex(c[I,a]),2) +string_char_at(dec_to_hex(c[I,a]),2); pcol[I,a]=draw_hex_color(pal[I,a]); // Set drawing color for palette box. }} All three apply the same value to all 3 colors, resulting in contrasting forms of Greyscaling, which I DON'T WANT! I know THAT is why my effect is not working correctly... but I don't know what exactly to do to fix this. Any help or suggestions? If this isn't clear enough I can try to elaborate more but am in a slight hurry to get the question out at the moment.
The "effect" shown on Wikipedia is used to illustrate what the different YUV components are. In reality, you're not going to be able to get that sort of effect on the MD due to limited color depth, and there's really no point in doing that anyway. It'll just result in a horribly undersaturated image that isn't very usable.
Yea... It was supposed to be for a color effect. I actually ended up getting this to work somewhat yesterday, though not 100% accurately... And though it wasn't exact, I can't say I really cared too much for the result... I was gonna keep tweaking it, but I guess I can just scrap it then... Oh we'll... Was worth a try though. I guess, back to the gradient builder I go then.