RGB to YUV to RGB
A J

i read somewhere that converting from RGB to YUV could be done with this

Y=.3R+.59G+.11B;
U=B-Y;
V=R-Y

but what is the conversion from YUV to RGB ?

Krzysztof Kluczek

Just treat it as three equations and solve it. :)

B=Y+U;
R=Y+V;
G=(Y-.3R-.11B)/.59;

Kitty Cat

Actually:

  R = 1.164*(Y - 16)                 + crv*(V - 128)
  G = 1.164*(Y - 16) - cgu*(U - 128) - cgv*(V - 128)
  B = 1.164*(Y - 16) + cbu*(U - 128)
// where:
  /* For SMPTE 170M (NTSC;MPEG-1) */
  crv = 1.596f;
  cbu = 2.018f;
  cgu = 0.391f;
  cgv = 0.813f;

Assuming input and output is between 0 and 255. You also need to be warry over overflow/underflow and clamp accordingly.

A J

Krzysztof Kluczek, i watch Shrek2 for the 1st time tonight..
nice avatar :)

Thread #429343. Printed from Allegro.cc