# Thread: YUY2 format, byte value?

1. What is YUY2 byte meaning? Y0?,U0?Y1?.....?Are they for color, which color?
Could you explain?
I have an image YUY2 format and I want to image processing on this format. But I dont know image byte value.
2. http://www.fourcc.org/

Bytes line up like this across the line.

YUY2 is a 4:2:2 standard

Y0 is a 8 bit luminance pixel component
U0 is a 8 bit (R-Y) pixel component
V0 is a 8 bit (B-Y) pixel component

All three represent a pixel on the screen. Since UV are half sampled, the next pixel would look like this

Y1
U0
V0

and so on ...

BTW: Green = Y-(Red-Y)-(Blue-Y) = Y-U-V

Does that help?
3. I understand from your note,
Y0= luminance of macropixel[0] that is two pixel of image.
U0= red value of macropixel[0]....
V0=blue value of macropixel[0]....
but Y1 =? Is this also for luminance of macropixel[0]?
4. Y=R+G+B=luminance=monochrome
U=R-Y
V=B-Y

Macropixels

Y0Y1|Y2Y3| etc.
U0U0|U2U2|
V0V0|V2V2|

"but Y1 =? Is this also for luminance of macropixel[0]?"

Pixel 1 = Y0-U0-V0
Pixel 2 = Y1-U0-V0

The two pixels represent a macropixel. Data byte order Y0-U0-Y1-V0

5. YUV/RGB conversion:

http://www.fourcc.org/fccyvrgb.php

Direct link to YUY2 format at fourcc:

http://www.fourcc.org/yuv.php#YUY2

6. The logic is that Y0 and Y1 do share the U0 and V0 Color compounds.
in YUY2 the HORIZONTAL Colorfrequency is half the lumafrequency in planar YV12 its even that Colorfrequency is a quarter (half vert. and half horiz.) of the Lumafrequency.

The YUYVYUYVYUYV order of YUY2 describes a packet/interleaved format where for example YV12 is a planar format.

So for parsing the Y Values you need to peek every second byte in the MemorySpace starting from first byte of the YUY2 Data memory adress+zero where the YUY2 Data is stored. For U then its the first byte +1 and then every fourth, for V its the first byte +3 and also here every fourth.
Put these into separate Y U V Arrays and you'll see again that the U and V arrays do will have a quarter of the Y array in their size each.

That alocation of bytes makes it possible to keep YUY2 and YV12 Data byte-alignet. BUT you have to watch out when parsing the values of these Y U V bytes as Y Values are stored as least significant bits (LSBs) and U and V values are stored as most significant bits (MSBs).

Means if Y < 0 then Y = Y + 256 ... for getting the common used Y value out of the LSB value.

So if Y = -16 the Y is 240! .. means highest lit value in Y luma range.

Also a very good page (dunno if it already has been mentioned in the posts above):
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwmt/html/YUVFormats.asp

Y=R+G+B=luminance=monochrome
U=R-Y
V=B-Y
R+G+B is not monochrome as its 24bit Color

When doing RGB to YUV conversions there are several maths according to CCIR Standards available as to bee seen in this link like posted some posts above:
http://www.fourcc.org/fccyvrgb.php
7. Originally Posted by incredible

Y=R+G+B=luminance=monochrome
U=R-Y
V=B-Y
R+G+B is not monochrome as its 24bit Color

When doing RGB to YUV conversions there are several maths according to CCIR Standards available as to bee seen in this link like posted some posts above:
http://www.fourcc.org/fccyvrgb.php
I was just trying to get accross the concept that luminance is a sum of red green and blue and the relationship to U and V. I got R-Y and B-Y reversed. Full equations are

Y = (0.257 * R) + (0.504 * G) + (0.098 * B) + 16
U = Cb = -(0.148 * R) - (0.291 * G) + (0.439 * B) + 128
V = Cr = (0.439 * R) - (0.368 * G) - (0.071 * B) + 128

Statistics