Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Announcements and Chat > General Discussion

Reply
 
Thread Tools Search this Thread Display Modes
Old 13th December 2011, 14:46   #1  |  Link
challanger
Registered User
 
Join Date: Dec 2011
Posts: 14
How can I understand yuv-rgb file

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?
challanger is offline   Reply With Quote
Old 13th December 2011, 15:44   #2  |  Link
2Bdecided
Registered User
 
Join Date: Dec 2002
Location: Yorkshire, UK
Posts: 1,673
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.
2Bdecided is offline   Reply With Quote
Old 13th December 2011, 23:51   #3  |  Link
challanger
Registered User
 
Join Date: Dec 2011
Posts: 14
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

Quote:
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?
challanger is offline   Reply With Quote
Old 14th December 2011, 01:35   #4  |  Link
Asmodian
Registered User
 
Join Date: Feb 2002
Location: San Jose, California
Posts: 2,677
yuv also keeps it's data as 8-bit, 0-255 luma, I think chroma is -128-127.
Asmodian is offline   Reply With Quote
Old 14th December 2011, 02:00   #5  |  Link
J_Darnley
Registered User
 
J_Darnley's Avatar
 
Join Date: May 2006
Posts: 959
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.
__________________
x264 log explained || x264 deblocking how-to
preset -> tune -> user set options -> fast first pass -> profile -> level
Doom10 - Of course it's better, it's one more.

Last edited by J_Darnley; 14th December 2011 at 02:09.
J_Darnley is offline   Reply With Quote
Old 14th December 2011, 15:21   #6  |  Link
challanger
Registered User
 
Join Date: Dec 2011
Posts: 14
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?
challanger is offline   Reply With Quote
Old 14th December 2011, 15:53   #7  |  Link
J_Darnley
Registered User
 
J_Darnley's Avatar
 
Join Date: May 2006
Posts: 959
Quote:
Originally Posted by challanger View Post
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.
__________________
x264 log explained || x264 deblocking how-to
preset -> tune -> user set options -> fast first pass -> profile -> level
Doom10 - Of course it's better, it's one more.
J_Darnley is offline   Reply With Quote
Old 14th December 2011, 16:46   #8  |  Link
challanger
Registered User
 
Join Date: Dec 2011
Posts: 14
Quote:
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 ?
challanger is offline   Reply With Quote
Old 14th December 2011, 17:09   #9  |  Link
J_Darnley
Registered User
 
J_Darnley's Avatar
 
Join Date: May 2006
Posts: 959
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
__________________
x264 log explained || x264 deblocking how-to
preset -> tune -> user set options -> fast first pass -> profile -> level
Doom10 - Of course it's better, it's one more.
J_Darnley is offline   Reply With Quote
Old 14th December 2011, 18:40   #10  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,924
Quote:
Originally Posted by J_Darnley View Post
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.
Guest is offline   Reply With Quote
Old 14th December 2011, 21:22   #11  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,376
Quote:
Originally Posted by J_Darnley View Post
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() in Avisynth.

Of course, there all the pixels are the same color, so the issue of chroma subsampling does not arise.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 14th December 2011, 22:23   #12  |  Link
challanger
Registered User
 
Join Date: Dec 2011
Posts: 14
Quote:
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

Last edited by challanger; 14th December 2011 at 23:07.
challanger is offline   Reply With Quote
Old 14th December 2011, 23:40   #13  |  Link
Asmodian
Registered User
 
Join Date: Feb 2002
Location: San Jose, California
Posts: 2,677
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.
Asmodian is offline   Reply With Quote
Old 15th December 2011, 11:44   #14  |  Link
2Bdecided
Registered User
 
Join Date: Dec 2002
Location: Yorkshire, UK
Posts: 1,673
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.
2Bdecided is offline   Reply With Quote
Reply

Tags
yuv rgb

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 20:33.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2017, vBulletin Solutions Inc.