View Full Version : How can I understand yuv-rgb file
challanger
13th December 2011, 14:46
Hi,
When I look into a video file with using mediainfo,there is a information about yuv.But when I analysis the video file's frames in matlab each pixels have a value between 1-255(I know 8bit rgb has values between this intervals).
Now I confused ,what is my video files color format;yuv or rgb?
How can I understand this?
http://img703.imageshack.us/img703/858/adszzfr.png
2Bdecided
13th December 2011, 15:44
MATLAB is converting the YUV video to RGB when loading?
Why do you want this in MATLAB? AVIsynth is better suited to video processing, while a 1Mbps XviD is hardly a good source for the kind of academic research you might undertake in MATLAB.
Cheers,
David.
challanger
13th December 2011, 23:51
First of all I want to learn that -when we look into my video properties shown in picture,can we say video color is yuv?
and
MATLAB is converting the YUV video to RGB when loading?
I didnt convert but when I read the video file each pixels have values between 1-255 so can we say matlab converted the color value yuv to rgb?
Asmodian
14th December 2011, 01:35
yuv also keeps it's data as 8-bit, 0-255 luma, I think chroma is -128-127.
J_Darnley
14th December 2011, 02:00
YUV is the common, quicker way to type Y'CbCr which is this colourspace: http://en.wikipedia.org/wiki/Y%27CbCr
4:2:0 is the chroma sub-sampling used: http://en.wikipedia.org/wiki/Chroma_subsampling
8-bit means how many bits per sample are used, almost: http://en.wikipedia.org/wiki/Color_depth
As for what happens when you load this file into your program, who knows? It is compressed, so you could be reading it without decoding; or reading the output of the decoder which should as mediainfo describes the file in which case it is more likely to be 16-235 luma and 16-240 chroma; or it has been converted to RGB for display in which case it is likely to be 0-255.
challanger
14th December 2011, 15:21
Thanks for help.
I newly leared that Matlab decompress my video and convert color space to RGB.Before I say Matlab looks like useless ,I want to try something else.It is that try to convert each pixel's RGB value to YUV.I have new question here;
I will calc y,u,v values using this formulas,
Y = 0.299R + 0.587G + 0.114B
U = -0.147R - 0.289G + 0.436B
V = 0.615R - 0.515G - 0.100B
for example. my first pixel's RGB value is 128.So R=128,G=B=0,
From there Y=38,U=18.86,V=78.72.
At this point How will I express first pixel's yuv value using this y-u-v values?
J_Darnley
14th December 2011, 15:53
I will calc y,u,v values using this formulas,
Y = 0.299R + 0.587G + 0.114B
U = -0.147R - 0.289G + 0.436B
V = 0.615R - 0.515G - 0.100B
for example. my first pixel's RGB value is 128.So R=128,G=B=0,
From there Y=38,U=18.86,V=78.72.
At this point How will I express first pixel's yuv value using this y-u-v values?
What do you mean by "How will I express first pixel's yuv value"? You have just expressed the example pixel.
If you mean "how do I do this in matlab?", then I have no idea. How does it store the RGB data? A simplistic example is to read one byte for red, one for green and one for blue, then convert to yuv and use as you necessary.
challanger
14th December 2011, 16:46
What do you mean by "How will I express first pixel's yuv value"? You have just expressed the example pixel.
For rgb R+G+B
for yuv y+u+v ?
J_Darnley
14th December 2011, 17:09
Oh, you mean as one value. Similar to the often seen hex values for RGB colours, e.g. FF0000 being red. I guess you could express YUV in a similar manner but I don't think I've seen it done elsewhere.
If you want to do this, a strict addition is wrong. For 8-bit: (R<<16) + (G<<8) + B
Guest
14th December 2011, 18:40
I guess you could express YUV in a similar manner but I don't think I've seen it done elsewhere.
It's not done because you can't do it for 4:2:0 sampling (without making up u and v values). If it is 4:4:4 it might make sense. But what is the need to put it into one number?
If you are going to make up u and v values, then you are effectively upsampling the chroma and there are lots of ways to do it.
Gavino
14th December 2011, 21:22
Oh, you mean as one value. Similar to the often seen hex values for RGB colours, e.g. FF0000 being red. I guess you could express YUV in a similar manner but I don't think I've seen it done elsewhere.
One place it is used is the color_yuv parameter of BlankClip (http://avisynth.org/mediawiki/BlankClip)() in Avisynth.
Of course, there all the pixels are the same color, so the issue of chroma subsampling does not arise.
challanger
14th December 2011, 22:23
But what is the need to put it into one number?
I'm in a project and at this step I have to calculate PSNR values for different codecs to compare video quality.But when I penetrate to subject,different parameters was appeared like yuv rgb.I just want to learn-Which color space (yuv or rgb or yCbCr) will reach me to the best conclusion for my test videos (All test videos yuv 4:2:0 subsampling like in the picture).Everyone offers yuv color space because of luma compenent but When I try to analyses video in Matlab,it converts yuv color space to rgb so I decide to reconvert each pixel's rbg value to YUV as a one number pixel value.Is this illogical??
If the answer is yes I ask this question again to do with Avisynth because matlab seems useless.
Which color space and script (yuv or rgb or yCbCr) will reach me to the best conclusion for my test videos to compare different codecs??.
Thanks again
Asmodian
14th December 2011, 23:40
From what I understand PSNR and other "quality metrics" are not a good way to measure codec quality. For example psy opimizations look better to humans but make PSNR etc. worse.
That said I assume doing one converson to RGB is better than doing YUV->RGB->YUV. Make sure you are doing the right YUV to RGB conversion, eg rec.601 or rec.709. You could also do the conversion to RGB in Avisynth where you probably have more control over it. Video is always converted to RGB at display so this isn't wrong IMO.
I don't really understand what you mean by "one number pixel value". Even going RGB->YUV 4:4:4 gives you three bytes per pixel. I guess you could concatenate the Y' byte, U byte, and V byte like RGB is sometimes expressed but no one would expect it.
2Bdecided
15th December 2011, 11:44
Google MATLAB PSNR for a start.
How should PSNR handle chroma? Do you have specifications/documentation? The scripts I found just do greyscale, which isn't much use in the real world.
How does the MATLAB function you're using for video handle different colour spaces etc? Have you checked its documentation? Is it just using DirectShow filters?
Cheers,
David.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.