Information about Yuv

Enlarge picture
Example of U-V color plane, Y value = 0.5, represented within RGB color gamut
Enlarge picture
Animation of all the possible RGB colors in the YUV color space. Time is Y, X-axis is U and Y-axis is V. (see image above) The black square delimits the (-0.5,-0.5)-(0.5,0.5) range.


The YUV model defines a color space in terms of one luma and two chrominance components. The YUV color model is used in the PAL, NTSC, and SECAM composite color video standards. Previous black-and-white systems used only luma (Y) information and color information (U and V) was added so that a black-and-white receiver would still be able to display a color picture as a normal black and white pictures.

YUV models human perception of color in a different way than the standard RGB model used in computer graphics hardware.

Y stands for the luma component (the brightness) and U and V are the chrominance (color) components. The YPbPr color model used in analog component video and its digital version YCbCr used in digital video are more or less derived from it (Cb/Pb and Cr/Pr are deviations from grey on blue-yellow and red-cyan axes, whereas U and V are blue-luminance and red-luminance differences), and are sometimes inaccurately called "YUV". The YIQ color space used in the analog NTSC television broadcasting system is related to it, although in a more complex way.

Mathematical derivations and formulae

YUV signals are created from an original RGB (red, green and blue) source. The weighted values of R, G, and B are added together to produce a single Y signal, representing the overall brightness, or luminance, of that spot. The U signal is then created by subtracting the Y from the blue signal of the original RGB, and then scaling; V is created by subtracting the Y from the red, and then scaling by a different factor. This can be accomplished easily with analog circuitry.

Mathematically, the analog version of YUV can be obtained from RGB with the following relationships



The U and V components can also be expressed in terms of raw R, G, and B, obtaining:



It is supposed, in all the previous equations, that .

As a consequence, the range of the transformed components is given by



The inverse relationship, from YUV to RGB, is given by



There are some points regarding the RGB transformation matrix:
  • The top row is identical to that of the YIQ color space
  • These formulae use the more traditional model of YUV, which is used for analog PAL equipment; digital PAL and digital NTSC HDTV do not use YUV but YCbCr.

Numerical approximations

Prior to the development of fast SIMD floating-point processors, most digital implementations of RGB->YUV used integer math, in particular fixed-point approximations. In the following examples, the operator "a >> b" denotes an integer division by a power of two, which is equivalent to a right-shift of a by b bits.

In 16-bit (modulo 65,536) arithmetic, we have

Y = min(abs(r * 2104 + g * 4130 + b * 802 + 4096 + 131072) >> 13, 235)
U = min(abs(r * -1214 + g * -2384 + b * 3598 + 4096 + 1048576) >> 13, 240)
V = min(abs(r * 3598 + g * -3013 + b * -585 + 4096 + 1048576) >> 13, 240)


whereas, for 8 bit (modulo 256) math, we have

Y = ( ( 66 * R + 129 * G + 25 * B + 128) >> 8) + 16
U = ( ( -38 * R - 74 * G + 112 * B + 128) >> 8) + 128
V = ( ( 112 * R - 94 * G - 18 * B + 128) >> 8) + 128

Luminance/chrominance systems in general

The primary advantages of luminance/chrominance systems such as YUV, and its relatives YIQ and YDbDr, are that they remain compatible with black and white analog television (largely due to the work of Georges Valensi). The Y channel saves nearly all the data recorded by black and white cameras, so it produces a signal suitable for reception on old monochrome displays. In this case, the U and V are simply discarded. If displaying color, all three channels are used, and the original RGB information can be decoded.

Another advantage of YUV is that some of the information can be discarded in order to reduce bandwidth. The human eye has fairly little color sensitivity: the accuracy of the brightness information of the luminance channel has far more impact on the image discerned than that of the other two. Understanding this human shortcoming, standards such as NTSC reduce the amount of data consumed by the chrominance channels considerably, leaving the eye to extrapolate much of the color. NTSC saves only 11% of the original blue and 30% of the red. The green information is usually preserved in the Y channel. Therefore, the resulting U and V signals can be substantially compressed.

However, this color space conversion is lossy. When the NTSC standard was created in the 1950s this was not a real concern since the quality of the image was limited by the monitor equipment, not the compressed signal being received. However today's modern television is capable of displaying more information than is contained in these lossy signals. To keep pace with the abilities of new technology, attempts have been made to preserve more of the YUV signal while recording images, such as S-Video on VCRs.

Instead of YUV, YCbCr was used as the standard format for (digital) common video compression algorithms such as MPEG-2. Digital television and DVDs preserve their compressed video streams in the MPEG-2 format, which uses a full YCbCr color space. The professional CCIR 601 uncompressed digital video format also uses YCbCr, primarily for compatibility with previous analog video standards. This stream can be easily mixed into any output format needed.

YUV is not an absolute color space. It is a way of encoding RGB information, and the actual color displayed depends on the actual RGB colorants used to display the signal. Therefore a value expressed as YUV is only predictable if standard RGB colorants are used (i.e. a fixed set of primary chromaticities, or particular set of red, green, and blue).

Confusion with YCbCr

YUV is often and mistakenly used as the term for YCbCr. However, they are different formats. YUV is an analog system with scale factors different than the digital YCbCr system.[1]

Types of sampling

To get a digital signal, YUV images can be sampled in several different ways; see chroma subsampling.

Converting from YUV to RGB

function RGB* YUV444toRGB888(Y, U, V); converts YUV format to simple RGB format and could be implemented using floating point arithmetic as:
  • YUV444
Y = 0.299R + 0.587G + 0.114B U = − 0.147R − 0.289G + 0.436B V = 0.615R − 0.515G − 0.100B

On older, non-SIMD architectures, floating point arithmetic is much slower than using [fixed point] arithmetic, so an alternative formulation is:

C = Y - 16 D = U - 128 E = V - 128

Using the previous coefficients and noting that clip() denotes clipping a value to the range of 0 to 255, the following formulas provide the conversion from YUV to RGB:

R = clip(( 298 * C + 409 * E + 128) >> 8) G = clip(( 298 * C - 100 * D - 208 * E + 128) >> 8) B = clip(( 298 * C + 516 * D + 128) >> 8)
  • YUV422
INPUT: Read 4 bytes of YUV (u, y1, v, y2 ) OUTPUT: Writes 6 bytes of RGB (R, G, B, R, G, B)

u = yuv[0]; y1 = yuv[1]; v = yuv[2]; y2 = yuv[3];

Using this information it could be parsed as regular YUV444 format to get 2 RGB pixels info:

rgb1 = YUV444toRGB888(y1, u, v); rgb2 = YUV444toRGB888(y2, u, v);

YUV422 can also be expressed in YUY2 FOURCC format code. That means 2 pixels will be defined in each macropixel (four bytes) treated in the image.
  • YUV411
// Extract yuv components u = yuv[0]; y1 = yuv[1]; y2 = yuv[2]; v = yuv[3]; y3 = yuv[4]; y4 = yuv[5];

rgb1 = YUV444toRGB888(y1, u, v); rgb2 = YUV444toRGB888(y2, u, v); rgb3 = YUV444toRGB888(y3, u, v); rgb4 = YUV444toRGB888(y4, u, v);

So the result is we are getting 4 RGB pixels values (4*3 bytes) from 6 bytes. This means reducing size of transferred data to half and with quite good loss of quality.
  • YUV420p (and YV12)
YUV420p is a planar format, meaning that the Y, U, and V values are grouped together instead of interspersed. The reason for this is that by grouping the U and V values together, the image becomes much more compressible. When given an array of an image in the YUV420p format, all the Y values come first, followed by all the U values, followed finally by all the V values.

The YV12 format is essentially the same as YUV420p, but it has the U and V data reversed: the Y values are followed by the V values, with the U values last. As long as care is taken to extract U and V values from the proper locations, both YUV420p and YV12 can be processed using the same algorithm.

As with most YUV formats, there are as many Y values as there are pixels. Where X equals the height multiplied by the width, the first X indices in the array are Y values that correspond to each individual pixel. However, there are only one fourth as many U and V values. The U and V values correspond to each 2 by 2 block of the image, meaning each U and V entry applies to four pixels. After the Y values, the next X/4 indices are the U values for each 2 by 2 block, and the next X/4 indices after that are the V values that also apply to each 2 by 2 block.

Translating YUV420p to RGB is a rather involved process compared to the previous formats. Taking a 16 by 16 image for example, getting the RGB values for pixel (5, 7) where (0, 0) is the top left pixel would be done as follows. The character "/" implies integer division, meaning that if there is a remainder, it will be discarded.

Height = 16; Width = 16; YArraySize = Height * Width = 256; Y = Array[7 * Width + 5]; U = Array[(7/2) * (Width/2) + 5/2 + YArraySize]; V = Array[(7/2) * (Width/2) + 5/2 + YArraySize + YArraySize/4];

RGB = YUV444toRGB888(Y, U, V);


As shown in the above image, the Y, U and V components in YUV420 are encoded separately in sequential blocks. A Y value is stored for every pixel, followed by a U value for each 2x2 square block of pixels, and finally a V value for each 2x2 block. Corresponding Y, U and V values are shown using the same color in the diagram above. Read line-by-line as a byte stream from a device, the Y block would be found at position 0, the U block at position x*y (6*4 = 24 in this example) and the V block at position x*y + (x*y)/4 (here, 6*4 + (6*4)/4 = 30).

Raw YCbCr streams are often stored in files with extension ".yuv". Here are some freely available examples for research purposes: [2] These are simply a sequence of YCbCr frames serialized into a byte stream.

See also

External links

color space. For example, Adobe RGB and sRGB are two different absolute color spaces, both based on the RGB model.

In the most generic sense of the definition above, color spaces can be defined without the use of a color model.
..... Click the link for more information.
As applied to video signals, luma represents the brightness in an image (the "black and white" or achromatic portion of the image). Luma is typically paired with chroma. Luma represents the achromatic image without any color, while the chroma components represent the color
..... Click the link for more information.
Chrominance (chroma for short), is the signal used in many video systems to carry the color information of the picture separately from the accompanying luma signal.
..... Click the link for more information.
PAL, short for Phase Alternating Line, is a colour encoding system used in broadcast television systems in large parts of the world. Other common analogue television systems are SECAM and NTSC.
..... Click the link for more information.
This article needs copy editing for grammar, style, cohesion, tone and/or spelling.
You can assist by [ editing it] now. A how-to guide is available, as is general .
This article has been tagged since October 2007.
..... Click the link for more information.
SECAM, also written SÉCAM (Séquentiel couleur à mémoire, French for "Sequential Color with Memory"), is an analog color television system first used in France.
..... Click the link for more information.
RGB color model is an additive model in which red, green, and blue (often used in additive light models) are combined in various ways to reproduce other colors. The name of the model and the abbreviation ‘RGB’ come from the three primary colors, red, green, and blue and
..... Click the link for more information.
As applied to video signals, luma represents the brightness in an image (the "black and white" or achromatic portion of the image). Luma is typically paired with chroma. Luma represents the achromatic image without any color, while the chroma components represent the color
..... Click the link for more information.
Chrominance (chroma for short), is the signal used in many video systems to carry the color information of the picture separately from the accompanying luma signal.
..... Click the link for more information.
YPbPr (also referred to as "Y/Pb/Pr", "YPrPb", "PrPbY", "B-Y R-Y Y" and "PbPrY") is a color space used in video electronics, in particular in reference to component video cables.
..... Click the link for more information.
Component video is a video signal that has been split into two or more components. In popular use, it refers to a type of analog video information that is transmitted or stored as three separate signals.
..... Click the link for more information.
YCbCr or Y'CbCr is a family of color spaces used in video and digital photography systems. Y' is the luma component and Cb and Cr are the blue and red chroma components. The prime on the Y is to distinguish the luma from luminance.
..... Click the link for more information.
YIQ is the color space used by the NTSC color TV system, employed mainly in North and Central America, and Japan. In the U.S., currently federally mandated for analog over-the-air TV broadcasting as shown in this excerpt of the current FCC rules and regulations part 73 "TV
..... Click the link for more information.
This article needs copy editing for grammar, style, cohesion, tone and/or spelling.
You can assist by [ editing it] now. A how-to guide is available, as is general .
This article has been tagged since October 2007.
..... Click the link for more information.
RGB color model is an additive model in which red, green, and blue (often used in additive light models) are combined in various ways to reproduce other colors. The name of the model and the abbreviation ‘RGB’ come from the three primary colors, red, green, and blue and
..... Click the link for more information.
Red is any of a number of similar colors evoked by light consisting predominantly of the longest wavelengths of light discernible by the human eye, in the wavelength range of roughly 625–750 nm.
..... Click the link for more information.
Green is a color, the perception of which is evoked by light having a spectrum dominated by energy with a wavelength of roughly 520–570 nm. It is considered one of the additive primary colors.
..... Click the link for more information.
The term blue may refer to any of a number of similar colours. The sensation of blue is made by light having a spectrum dominated by energy in the wavelength range of about 440–490 nm.
..... Click the link for more information.
YIQ is the color space used by the NTSC color TV system, employed mainly in North and Central America, and Japan. In the U.S., currently federally mandated for analog over-the-air TV broadcasting as shown in this excerpt of the current FCC rules and regulations part 73 "TV
..... Click the link for more information.
PAL, short for Phase Alternating Line, is a colour encoding system used in broadcast television systems in large parts of the world. Other common analogue television systems are SECAM and NTSC.
..... Click the link for more information.
PAL, short for Phase Alternating Line, is a colour encoding system used in broadcast television systems in large parts of the world. Other common analogue television systems are SECAM and NTSC.
..... Click the link for more information.
This article needs copy editing for grammar, style, cohesion, tone and/or spelling.
You can assist by [ editing it] now. A how-to guide is available, as is general .
This article has been tagged since October 2007.
..... Click the link for more information.
High-definition television (HDTV) is a digital television broadcasting system with a significantly higher resolution than traditional formats (NTSC, SECAM, PAL). While some early analog HDTV formats were broadcast in Europe and Japan, HDTV is usually broadcast digitally,
..... Click the link for more information.
Flynn's Taxonomy
  Single
Instruction Multiple
Instruction
Single
Data SISD MISD
Multiple
Data SIMD MIMD In computing, SIMD (Single Instruction, Multiple D
..... Click the link for more information.
"Fixed point" has many meanings in science, most of them mathematical.
  • Fixed point (mathematics)
  • Fixed point combinator
  • Fixed-point arithmetic, a manner of doing arithmetic on computers
  • For fixed points in physics, see Renormalization group

..... Click the link for more information.
Modular arithmetic (sometimes called modulo arithmetic, or clock arithmetic) is a system of arithmetic for integers, where numbers "wrap around" after they reach a certain value — the modulus.
..... Click the link for more information.
YIQ is the color space used by the NTSC color TV system, employed mainly in North and Central America, and Japan. In the U.S., currently federally mandated for analog over-the-air TV broadcasting as shown in this excerpt of the current FCC rules and regulations part 73 "TV
..... Click the link for more information.
YDbDr is the colour space used in the SÉCAM colour television broadcasting standard, which is used in France and some countries of the former Eastern Bloc. It is very close to YUV and its related colour spaces such as YIQ, YPbPr and YCbCr.
..... Click the link for more information.
Analog television (or analogue television) encodes television and transports the picture and sound information as an analog signal, that is, by varying the amplitude and/or frequencies of the broadcast signal.
..... Click the link for more information.
Georges Valensi was a French telecommunications engineer who, in 1938, invented and patented a method of transmitting color images so that they could be received on both color and black & white television sets.
..... Click the link for more information.


This article is copied from an article on Wikipedia.org - the free encyclopedia created and edited by online user community. The text was not checked or edited by anyone on our staff. Although the vast majority of the wikipedia encyclopedia articles provide accurate and timely information please do not assume the accuracy of any particular article. This article is distributed under the terms of GNU Free Documentation License.
Herod_Archelaus


page counter