Please help newbie problem with RGB->YUV conversion

Please help newbie problem with RGB->YUV conversion

Post by Maurizi » Wed, 30 Jul 2003 23:14:37


Hi,i-ve a problem with converting rgb in yuv.
I must convert a rgb image into a yuv 420P image, the problem is that
after
this conversion only green values is c is converted correctly, blue and
red value are gone,maybe not converted (=my image is all in light
green/dark green).
This is my code:
/* Y */
for(y=0;y<height;y++) {
for(x=0;x<width;x++) {
pict->data[0][y * pict->linesize[0] + x] =
+0.257*imagedata[temp]+0.504*imagedata[1+temp]+0.098*imagedata[2+temp];
temp=temp+3;
}
}
temp=0;
/*U and V*/
for(y=0;y<height/2;y++) {
for(x=0;x<width/2;x++) {
pict->data[1][y * pict->linesize[1] + x] =
(+0.439*imagedata[temp]-0.368*imagedata[1+temp]-0.071*imagedata[2+temp])+128;
pict->data[2][y * pict->linesize[2] + x] =
(-0.148*imagedata[temp]-0.291*imagedata[1+temp]+0.439*imagedata[2+temp])+128;
temp=temp+3;
}
}

imagedata is my rgb value and pict->data is my yuv 420P picture.
Please help, sorry for my english.
Thanks in advance.
 
 
 

1. RGB to YUV and YUV to RGB Questions

2. How to find color matrix for YUV->RGB conversion


I'm not sure what you mean by "color matrix" but here is a good site which
summarizes YUV and RGB types:

http://www.yqcomputer.com/

In dshow, if you look at the video media subtype GUID, the first four bytes
tell you the FourCC.

Here is an overview of conversions:

http://www.yqcomputer.com/

--
Please read this before replying:
1. Dshow & posting help: http://www.yqcomputer.com/
2. Trim & respond inline (please don't top post or snip everything)
3. Benefit others: follow up if you are helped or you found a solution

3. about conversion from YUV to RGB

4. ARM ASM YUV RGB CONVERSION

5. YUV to RGB conversion

6. YUV/RGB conversion and smooth WMV-HD playback

7. YUV to RGB conversion in OV7620

8. YUV/RGB conversion and smooth WMV-HD playback

9. Top posting vs. bottom posting (was ARM ASM YUV RGB CONVERSION)

10. Relation ship of constants in yuv<->rgb formula's ?

11. RGB -> YUV (MMX)

12. Ask for yuv<->rgb transform matrix used in DirectShow

13. RGB->YUV

14. RGB <> Lab <> RGB