Home      Discussion      Topics      Dictionary      Almanac
Signup       Login
YUV

YUV

Overview

YUV is a color space
Color space
A color model is an abstract mathematical model describing the way colors can be represented as tuples of numbers, typically as three or four values or color components...

 typically used as part of a color image pipeline
Color image pipeline
An image pipeline or video pipeline is a term used to describe the components that are typically or commonly used between an image source , and an image renderer , or for performing any intermediate digital image processing...

. It encodes a color image or video taking human perception into account, allowing reduced bandwidth for chrominance
Chrominance
Chrominance , is the signal used in video systems to convey the color information of the picture, separately from the accompanying luma signal. Chrominance is usually represented as two color-difference components: U = B'–Y' and V = R'–Y'...

 components, thereby typically enabling transmission errors or compression artifacts to be more efficiently masked by the human perception than using a "direct" RGB-representation. Other color spaces have similar properties, and the main reason to implement or investigate properties of Y'UV would be for interfacing with analog or digital television or photographic equipment that conforms to certain Y'UV standards.

The scope of the terms Y'UV, YUV, YCbCr
YCbCr
YCbCr or Y'CbCr is a family of color spaces used as a part of the Color image pipeline in video and digital photography systems. Y' is the luma component and Cb and Cr are the blue-difference and red-difference chroma components...

, YPbPr
YPbPr
' is a color space used in video electronics, in particular in reference to component video cables. is the analog version of the YCBCR color space; the two are numerically equivalent, but YPBPR is designed for use in analog systems whereas...

, etc., is sometimes ambiguous and overlapping.
Discussion
Ask a question about 'YUV'
Start a new discussion about 'YUV'
Answer questions from other users
Full Discussion Forum
 
Encyclopedia

YUV is a color space
Color space
A color model is an abstract mathematical model describing the way colors can be represented as tuples of numbers, typically as three or four values or color components...

 typically used as part of a color image pipeline
Color image pipeline
An image pipeline or video pipeline is a term used to describe the components that are typically or commonly used between an image source , and an image renderer , or for performing any intermediate digital image processing...

. It encodes a color image or video taking human perception into account, allowing reduced bandwidth for chrominance
Chrominance
Chrominance , is the signal used in video systems to convey the color information of the picture, separately from the accompanying luma signal. Chrominance is usually represented as two color-difference components: U = B'–Y' and V = R'–Y'...

 components, thereby typically enabling transmission errors or compression artifacts to be more efficiently masked by the human perception than using a "direct" RGB-representation. Other color spaces have similar properties, and the main reason to implement or investigate properties of Y'UV would be for interfacing with analog or digital television or photographic equipment that conforms to certain Y'UV standards.

The scope of the terms Y'UV, YUV, YCbCr
YCbCr
YCbCr or Y'CbCr is a family of color spaces used as a part of the Color image pipeline in video and digital photography systems. Y' is the luma component and Cb and Cr are the blue-difference and red-difference chroma components...

, YPbPr
YPbPr
' is a color space used in video electronics, in particular in reference to component video cables. is the analog version of the YCBCR color space; the two are numerically equivalent, but YPBPR is designed for use in analog systems whereas...

, etc., is sometimes ambiguous and overlapping. Historically, the terms YUV and Y'UV were used for a specific analog encoding of color information in television systems, while YCbCr was used for digital encoding of color information suited for video and still-image compression and transmission such as MPEG and JPEG
JPEG
In computing, JPEG is a commonly used method of compression for photographic images. The degree of compression can be adjusted, allowing a selectable tradeoff between storage size and image quality...

. Today, the term YUV is commonly used in the computer industry to describe file-formats that are encoded using YCbCr.

The Y'UV model defines a color space
Color space
A color model is an abstract mathematical model describing the way colors can be represented as tuples of numbers, typically as three or four values or color components...

 in terms of one luma
Luma (video)
As applied to video signals, luma represents the brightness in an image . Luma is typically paired with chroma. Luma represents the achromatic image without any color, while the chroma components represent the color information. Converting R'G'B' sources As applied to video signals, luma...

 (Y') and two chrominance
Chrominance
Chrominance , is the signal used in video systems to convey the color information of the picture, separately from the accompanying luma signal. Chrominance is usually represented as two color-difference components: U = B'–Y' and V = R'–Y'...

 (UV) components. The Y'UV color model is used in the NTSC
NTSC
NTSC, named for the National Television System Committee is the analog television system used in most of the Americas, Japan, South Korea, Taiwan, Burma, and some Pacific island nations and territories . is also the name of the U.S. standardization body that developed the broadcast standard...

, PAL
PAL
PAL, short for Phase Alternating Line, is an analogue television encoding system used in broadcast television systems in large parts of the world. Other common analogue television systems are SECAM and NTSC. This page primarily discusses the colour encoding system...

, and SECAM
SECAM
SECAM, also written SÉCAM , is an analog color television system first used in France....

 composite color video
Composite video
Composite video is the format of an analog television signal before it is combined with a sound signal and modulated onto an RF carrier.Composite video is often designated by the CVBS acronym, meaning "Color, Video, Blank and Sync"...

 standards. Previous black-and-white systems used only luma (Y') information. Color information (U and V) was added separately via a sub-carrier so that a black-and-white receiver would still be able to receive and display a color picture transmission in the receiver's native black-and-white
Black-and-white
Black-and-white is a number of monochrome forms in visual arts. Most forms of visual technology start out in black and white, then slowly evolve into color as technology progresses....

 format.

Y' stands for the luma
Luma (video)
As applied to video signals, luma represents the brightness in an image . Luma is typically paired with chroma. Luma represents the achromatic image without any color, while the chroma components represent the color information. Converting R'G'B' sources As applied to video signals, luma...

 component (the brightness) and U and V are the chrominance
Chrominance
Chrominance , is the signal used in video systems to convey the color information of the picture, separately from the accompanying luma signal. Chrominance is usually represented as two color-difference components: U = B'–Y' and V = R'–Y'...

 (color) components; luminance is denoted by Y and luma by Y' – the prime symbols (') denote gamma compression,
with "luminance" meaning perceptual (color science) brightness, while "luma" is electronic (voltage of display) brightness.
The YPbPr
YPbPr
' is a color space used in video electronics, in particular in reference to component video cables. is the analog version of the YCBCR color space; the two are numerically equivalent, but YPBPR is designed for use in analog systems whereas...

 color model used in analog component video
Component video
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. Component video can be contrasted with composite video in which all the video information is...

 and its digital version YCbCr
YCbCr
YCbCr or Y'CbCr is a family of color spaces used as a part of the Color image pipeline in video and digital photography systems. Y' is the luma component and Cb and Cr are the blue-difference and red-difference chroma components...

 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 called Y'UV. The Y'IQ
YIQ
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 transmission standard":I...

 color space used in the analog NTSC
NTSC
NTSC, named for the National Television System Committee is the analog television system used in most of the Americas, Japan, South Korea, Taiwan, Burma, and some Pacific island nations and territories . is also the name of the U.S. standardization body that developed the broadcast standard...

 television broadcasting system is related to it, although in a more complex way.

History


Y'UV was invented when engineers wanted color television
Color television
Color television refers to the technology and practices associated with television's transmission of moving images in color.In its most basic form, a color broadcast can be created by broadcasting three monochrome images, one each in the three colors of red, green and blue...

 in a black-and-white
Black-and-white
Black-and-white is a number of monochrome forms in visual arts. Most forms of visual technology start out in black and white, then slowly evolve into color as technology progresses....

 infrastructure. They needed a signal transmission method that was compatible with black-and-white (B&W) TV while being able to add color. The luma component already existed as the B&W signal; they added the UV signal to this as a solution.

The UV representation of chrominance was chosen over, say, straight R and B signals because U and V are color difference signals. This meant that in a B&W scene the U and V signals would be zero and only the Y' signal would be transmitted. If R and B were to have been used, these would have non-zero values even in a B&W scene. This was important in the early days of color television as many programs were still being made and transmitted in B&W and many TV receivers were B&W only. It was necessary to assign a narrower bandwidth to the chrominance channel (there was no additional bandwidth available) and having some of the luminance information arrive via the chrominance channel - an inevitable consequence of Y'RB - would have resulted in a loss of B&W resolution.

Mathematical derivations and formulas


Y'UV signals are typically created from an original RGB (red
Red
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 630–740 nm. Longer wavelengths than this are called infrared , and cannot be seen by the naked human eye...

, green
Green
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 nanometres. In the subtractive color system, it is not a primary color, but is created out of a mixture of yellow and blue, or yellow and cyan; it is considered...

 and blue
Blue
Blue is a colour, the perception of which is evoked by light having a spectrum dominated by energy with a wavelength of roughly 440–490 nm. It is considered one of the additive primary colours. On the HSV Colour Wheel, the complement of blue is yellow; that is, a colour corresponding to an equal...

) 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.

The relationship between Y'UV and RGB is dependent on the following defined constants:
Then Y'UV is given in terms of RGB as (with R, G, B ranging from zero to one):
Note that the ranges of Y', U, and V respectively are [0, 1], [-UMax, UMax], and [-VMax, VMax]. The above is a linear transform which can be easily inverted:
Equivalently, substituting numbers for symbols:
There are some points regarding the RGB transformation matrix:
  • The top row is identical to that of the Y'IQ
    YIQ
    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 transmission standard":I...

     color space
  • These formulae use the more traditional model of Y'UV, which is used for analog PAL
    PAL
    PAL, short for Phase Alternating Line, is an analogue television encoding system used in broadcast television systems in large parts of the world. Other common analogue television systems are SECAM and NTSC. This page primarily discusses the colour encoding system...

     equipment; digital PAL
    PAL
    PAL, short for Phase Alternating Line, is an analogue television encoding system used in broadcast television systems in large parts of the world. Other common analogue television systems are SECAM and NTSC. This page primarily discusses the colour encoding system...

     and digital NTSC
    NTSC
    NTSC, named for the National Television System Committee is the analog television system used in most of the Americas, Japan, South Korea, Taiwan, Burma, and some Pacific island nations and territories . is also the name of the U.S. standardization body that developed the broadcast standard...

     HDTV
    High-definition television
    High-definition television is a digital television broadcasting system with higher resolution than traditional television systems...

     do not use YUV but YCbCr.

BT.709 and BT.601


When standardising high-definition video
High-definition video
High-definition video or HD video refers to any video system of higher resolution than standard-definition video, and most commonly involves display resolutions of 1280×720 pixels or 1920×1080 pixels...

, the ATSC
ATSC
ATSC is a set of standards developed by the Advanced Television Systems Committee for digital television transmission that replaced much of the analog NTSC television system on June 12, 2009 in the United States and will replace NTSC by August 31, 2011 in Canada and December 31, 2021 in Mexico.The...

 chose a different formula for the YCbCr than that used for standard-definition video. This means that when converting between SDTV and HDTV, the color information has to be altered, in addition to image scaling
Image scaling
In computer graphics, image scaling is the process of resizing a digital image. Scaling is a non-trivial process that involves a trade-off between efficiency, smoothness and sharpness. As the size of an image is increased, so the pixels which comprise the image become increasingly visible, making...

 the video.

The formulas above reference Rec. 601. For HDTV, a slightly different matrix is used, where WR and WB in the above formula is replaced by Rec. 709
Rec. 709
ITU-R Recommendation BT.709, more commonly known by the abbreviations Rec. 709 or BT.709, standardizes the format of High-definition television, having 16:9 aspect ratio.-Pixel count:...

:

Numerical approximations


Prior to the development of fast SIMD
SIMD
In computing, SIMD is a technique employed to achieve data level parallelism.- History :...

 floating-point processors, most digital implementations of RGB->Y'UV 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.

Traditional 8 bit representation of Y'UV with unsigned integers uses the following

Basic Transform
Scale down to 8 bits with rounding
Shift values

Y' values are conventionally shifted and scaled to the range [16, 235] rather than using the full range of [0, 255]. This confusing practice derives from the MPEG standards and explains why 16 is added to Y' and why the Y' coefficients in the basic transform sum to 220 instead of 255. U and V values, which may be positive or negative, are summed with 128 to make them always positive.

RGB to Y'UV conversion using 16 bit coefficients:
Y'UV to RGB conversion using 16 bit coefficients:

Luminance/chrominance systems in general


The primary advantages of luma/chroma systems such as Y'UV, and its relatives Y'IQ
YIQ
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 transmission standard":I...

 and YDbDr
YDbDr
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....

, are that they remain compatible with black and white analog television
Analog television
Analog television encodes television picture and sound information and transmits it as an analog signal: one in which the message conveyed by the broadcast signal is a function of deliberate variations in the amplitude and/or frequency of the signal...

 (largely due to the work of Georges Valensi
Georges Valensi
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....

). 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 Y'UV 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
NTSC
NTSC, named for the National Television System Committee is the analog television system used in most of the Americas, Japan, South Korea, Taiwan, Burma, and some Pacific island nations and territories . is also the name of the U.S. standardization body that developed the broadcast standard...

 reduce the bandwidth of the chrominance channels considerably, leaving the brain to extrapolate much of the color.

Therefore, the resulting U and V signals can be substantially "compressed". (In the NTSC (Y'IQ) and PAL systems, the chrominance signals had significantly narrower bandwidth (roughly 1 MHz) than that for the luminance.) The I and Q axes were chosen according to bandwidth needed by human vision, one axis being that requiring the most bandwidth, and the other (fortuitously at 90 degrees) the minimum. However, true I and Q demodulation was relatively more complex, requiring two analog delay lines, and NTSC receivers rarely used it.

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 limited-bandwidth 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 Y'UV signal while recording images, such as S-Video
S-Video
Separate Video, more commonly known as S-Video, and sometimes incorrectly referred to as Super Video and also known as Y/C, is an analog video signal that carries video data as two separate signals: lumen and chroma...

 on VCR
Videocassette recorder
The videocassette recorder , is a type of video tape recorder that uses removable videotape cassettes containing magnetic tape to record audio and video from a television broadcast so it can be played back later...

s.

Instead of Y'UV, Y'CbCr was used as the standard format for (digital) common video compression
Video compression
Video compression refers to reducing the quantity of data used to represent digital video images, and is a combination of spatial image compression and temporal motion compensation. Video compression is an example of the concept of source coding in Information theory...

 algorithms such as MPEG-2
MPEG-2
MPEG-2 is a standard for "the generic coding of moving pictures and associated audio information". It describes a combination of lossy video compression and lossy audio data compression methods which permit storage and transmission of movies using currently available storage media and transmission...

. Digital television and DVDs preserve their compressed video
Video compression
Video compression refers to reducing the quantity of data used to represent digital video images, and is a combination of spatial image compression and temporal motion compensation. Video compression is an example of the concept of source coding in Information theory...

 streams in the MPEG-2
MPEG-2
MPEG-2 is a standard for "the generic coding of moving pictures and associated audio information". It describes a combination of lossy video compression and lossy audio data compression methods which permit storage and transmission of movies using currently available storage media and transmission...

 format, which uses a full Y'CbCr color space. The professional CCIR 601
CCIR 601
ITU-R Recommendation BT.601, more commonly known by the abbreviations Rec. 601 or BT.601 is a standard published by International Telecommunication Union - Radiocommunications sector for encoding interlaced analogue video signals in digital form...

 uncompressed digital video format also uses Y'CbCr, primarily for compatibility with previous analog video standards. This stream can be easily mixed into any output format needed.

Y'UV is not an absolute color space
Absolute color space
In color science, there are two meanings of the term absolute color space:* A color space in which the perceptual difference between colors is directly related to distances between colors as represented by points in the 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 Y'UV 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 Y'CbCr


Y'UV is often used as the term for YCbCr
YCbCr
YCbCr or Y'CbCr is a family of color spaces used as a part of the Color image pipeline in video and digital photography systems. Y' is the luma component and Cb and Cr are the blue-difference and red-difference chroma components...

. However, they are different formats. Y'UV is an analog system with scale factors different from the digital Y'CbCr system.

In digital video/image systems, Y'CbCr is the most common way to express color in a way suitable for compression/transmission. The confusion stems from computer implementations and text-books erroneously using the term YUV where Y'CbCr would be correct.

Types of sampling


To get a digital signal, Y'UV images can be sampled in several different ways; see chroma subsampling
Chroma subsampling
Chroma subsampling is the practice of encoding images by implementing less resolution for chroma information than for luma information. It is used in many video encoding schemes — both analog and digital — and also in JPEG encoding.-Rationale:...

.

Converting between Y'UV and RGB


The function [R, G, B] = Y'UV444toRGB888(Y', U, V) converts Y'UV format to simple RGB format and could be implemented using floating point arithmetic as:

Y'UV444


The RGB conversion formulas used for Y'UV444 format are also applicable to the standard NTSC TV transmission format of YUV420 (or YUV422 for that matter). For YUV420, since each U or V sample is used to represent 4 Y samples that form a square, a proper sampling method can allow the utilization of the exact conversion formulas shown below. For more details, please see the 420 format demonstration in the bottom section of this article.

These formulae are based on the NTSC standard;

On older, non-SIMD
SIMD
In computing, SIMD is a technique employed to achieve data level parallelism.- History :...

 architectures, floating point arithmetic is much slower than using fixed-point arithmetic, so an alternative formulation is:
Using the previous coefficients and noting that clip denotes clipping a value to the range of 0 to 255, the following formulae provide the conversion from Y'UV to RGB (NTSC version):
Note: The above formulae are actually implied for YCbCr.
Though the term YUV is used here, it should be noted that YUV and YCbCr are not exactly the same in a strict manner.

The ITU-R version of the formulae is different:
Integer operation of ITU-R standard for YCbCr(8 bits per channel) to RGB888:

Cr = Cr - 128;
Cb = Cb - 128;

Y'UV422

Input: Read 4 bytes of Y'UV (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 Y'UV444 format to get 2 RGB pixels info:

rgb1 = Y'UV444toRGB888(y1, u, v);
rgb2 = Y'UV444toRGB888(y2, u, v);
Y'UV422 can also be expressed in YUY2 FourCC
FourCC
A FourCC is a sequence of four bytes used to uniquely identify data formats. The concept originated in the OSType scheme used in the Macintosh system software and was adopted for the Amiga/Electronic Arts Interchange File Format and derivatives...

format code. That means 2 pixels will be defined in each macropixel (four bytes) treated in the image.

Y'UV411


// Extract YUV components
u = yuv[0];
y1 = yuv[1];
y2 = yuv[2];
v = yuv[3];
y3 = yuv[4];
y4 = yuv[5];

rgb1 = Y'UV444toRGB888(y1, u, v);
rgb2 = Y'UV444toRGB888(y2, u, v);
rgb3 = Y'UV444toRGB888(y3, u, v);
rgb4 = Y'UV444toRGB888(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.

Y'UV420p (and Y'V12)


Y'UV420p 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 Y'UV420p format, all the Y' values come first, followed by all the U values, followed finally by all the V values.

The Y'V12 format is essentially the same as Y'UV420p, 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 Y'UV420p and Y'V12 can be processed using the same algorithm.

As with most Y'UV 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 Y'UV420p 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;
Y'ArraySize = Height × Width; // (256)
Y' = Array[7 × Width + 5];
U = Array[(7/2) × (Width/2) + 5/2 + Y'ArraySize];
V = Array[(7/2) × (Width/2) + 5/2 + Y'ArraySize + Y'ArraySize/4];

RGB = Y'UV444toRGB888(Y', U, V);



As shown in the above image, the Y', U and V components in Y'UV420 are encoded separately in sequential blocks. A Y' value is stored for every pixel, followed by a U value for each 2×2 square block of pixels, and finally a V value for each 2×2 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).

External links