HOME

TheInfoList



OR:

YUV is a color model typically used as part of a color image pipeline. It encodes a
color image A digital image is an image composed of picture elements, also known as ''pixels'', each with '' finite'', '' discrete quantities'' of numeric representation for its intensity or gray level that is an output from its two-dimensional functions ...
or video taking
human perception Perception () is the organization, identification, and interpretation of sensory information in order to represent and understand the presented information or environment. All perception involves signals that go through the nervous syste ...
into account, allowing reduced
bandwidth Bandwidth commonly refers to: * Bandwidth (signal processing) or ''analog bandwidth'', ''frequency bandwidth'', or ''radio bandwidth'', a measure of the width of a frequency range * Bandwidth (computing), the rate of data transfer, bit rate or thr ...
for
chrominance Chrominance (''chroma'' or ''C'' for short) is the signal used in video systems to convey the color information of the picture (see YUV color model), separately from the accompanying luma signal (or Y' for short). Chrominance is usually represen ...
components, compared to a "direct"
RGB The RGB color model is an additive color model in which the red, green and blue primary colors of light are added together in various ways to reproduce a broad array of colors. The name of the model comes from the initials of the three additi ...
-representation. Historically, the terms YUV and Y′UV were used for a specific ''analog encoding'' of color information in television systems. Today, the term YUV is commonly used in the computer industry to describe colorspaces that are encoded using
YCbCr YCbCr, Y′CbCr, or Y Pb/Cb Pr/Cr, also written as 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-dif ...
. The YUV model defines one
luminance Luminance is a photometric measure of the luminous intensity per unit area of light travelling in a given direction. It describes the amount of light that passes through, is emitted from, or is reflected from a particular area, and falls with ...
component (Y) meaning physical linear-space brightness, and two
chrominance Chrominance (''chroma'' or ''C'' for short) is the signal used in video systems to convey the color information of the picture (see YUV color model), separately from the accompanying luma signal (or Y' for short). Chrominance is usually represen ...
components, called U (blue projection) and V (red projection) respectively. It can be used to convert to and from the RGB model, and with different
color space A color space is a specific organization of colors. In combination with color profiling supported by various physical devices, it supports reproducible representations of colorwhether such representation entails an analog or a digital represen ...
s. The closely related Y′UV model uses the luma component (Y′) – nonlinear perceptual brightness, with the prime symbols (') denoting
gamma correction Gamma correction or gamma is a nonlinear operation used to encode and decode luminance or tristimulus values in video or still image systems. Gamma correction is, in the simplest cases, defined by the following power-law expression: : V_\text ...
. Y′UV is used in the
PAL Phase Alternating Line (PAL) is a colour encoding system for analogue television. It was one of three major analogue colour television standards, the others being NTSC and SECAM. In most countries it was broadcast at 625 lines, 50 fields ( ...
analogue color TV standard (excluding
PAL-N Phase Alternating Line (PAL) is a colour encoding system for analogue television. It was one of three major analogue colour television standards, the others being NTSC and SECAM. In most countries it was broadcast at 625 lines, 50 fields (25 ...
). Previous black-and-white systems used only luma (Y′) information. Color information (U and V) was added separately via a
subcarrier A subcarrier is a sideband of a radio frequency carrier wave, which is modulated to send additional information. Examples include the provision of colour in a black and white television system or the provision of stereo in a monophonic radio bro ...
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 (B&W or B/W) images combine black and white in a continuous spectrum, producing a range of shades of grey. Media The history of various visual media began with black and white, and as technology improved, altered to color. ...
format, with no need for extra transmission bandwidth. As for etymology, Y, Y′, U, and V are not abbreviations. The use of the letter Y for luminance can be traced back to the choice of XYZ primaries. This lends itself naturally to the usage of the same letter in luma (Y′), which approximates a
perceptually uniform In color science, color difference or color distance is the separation between two colors. This metric allows quantified examination of a notion that formerly could only be described with adjectives. Quantification of these properties is of great ...
correlate of luminance. Likewise, U and V were chosen to differentiate the U and V axes from those in other spaces, such as the x and y chromaticity space. See the equations below or compare the historical development of the math.


Related color models

The scope of the terms Y′UV, YUV, YCbCr, YPbPr, etc., is sometimes ambiguous and overlapping. Historically, YUV and Y′UV were used for referring to analog television systems. But the same designation is sometimes applied to
YCbCr YCbCr, Y′CbCr, or Y Pb/Cb Pr/Cr, also written as 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-dif ...
, used for ''digital encoding'' of color information suited for video and image compression and transmission formats such as
MPEG The Moving Picture Experts Group (MPEG) is an alliance of working groups established jointly by ISO and IEC that sets standards for media coding, including compression coding of audio, video, graphics, and genomic data; and transmission and ...
and
JPEG JPEG ( ) is a commonly used method of lossy compression for digital images, particularly for those images produced by digital photography. The degree of compression can be adjusted, allowing a selectable tradeoff between storage size and im ...
. Likewise, the
YPbPr YPbPr or Y'PbPr, also written as , is a color space used in video electronics, in particular in reference to component video cables. YPBPR is gamma corrected YCBCR color space (it is not analog YUV that was used for analog TV, though component ...
color model used in analog
component video Component video is an analog video signal that has been split into two or more component channels. In popular use, it refers to a type of component analog video (CAV) information that is transmitted or stored as three separate signals. Compon ...
is sometimes called Y′UV. On these color models CB/PB and CR/PR are deviations from grey on blue–yellow and red–cyan axes, whereas on YUV U and V are blue–luminance and red–luminance differences respectively. The Y′IQ color model used in the analog
NTSC The first American standard for analog television broadcast was developed by National Television System Committee (NTSC)National Television System Committee (1951–1953), Report and Reports of Panel No. 11, 11-A, 12–19, with Some supplement ...
television broadcasting system also broadly follows the same principles as YUV, although in a more complex way. The
YDbDr YDbDr, sometimes written YDBDR, is the colour space used in the SECAM analog terrestrial colour television broadcasting standard (adopted in France and some countries of the former Eastern Bloc) and PAL-N (adopted in Argentina, Paraguay and Urug ...
color model, used in the analog
SECAM SECAM, also written SÉCAM (, ''Séquentiel de couleur à mémoire'', French for ''color sequential with memory''), is an analog color television system that was used in France, some parts of Europe and Africa, and Russia. It was one of th ...
and
PAL-N Phase Alternating Line (PAL) is a colour encoding system for analogue television. It was one of three major analogue colour television standards, the others being NTSC and SECAM. In most countries it was broadcast at 625 lines, 50 fields (25 ...
television broadcasting systems, is also related.


History

Y′UV was invented when engineers wanted color television in a
black-and-white Black-and-white (B&W or B/W) images combine black and white in a continuous spectrum, producing a range of shades of grey. Media The history of various visual media began with black and white, and as technology improved, altered to color. ...
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 black and white signal; they added the UV signal to this as a solution. The UV representation of chrominance was chosen over straight R and B signals because U and V are color difference signals. In other words, the U and V signals tell the television to shift the color of a certain spot without altering its brightness. Or the U and V signals tell the monitor to make one color brighter at the cost of the other and by how much it should be shifted. The higher (or the lower when negative) the U and V values are, the more saturated (colorful) the spot gets. The closer the U and V values get to zero, the lesser it shifts the color meaning that the red, green and blue lights will be more equally bright, producing a greyer spot. This is the benefit of using color difference signals, i.e. instead of telling how much red there is to a color, it tells by how much it is more red than green or blue. In turn this meant that when the U and V signals would be zero or absent, it would just display a greyscale image. If R and B were to have been used, these would have non-zero values even in a B&W scene, requiring all three data-carrying signals. This was important in the early days of color television, because old black and white TV signals had no U and V signals present, meaning the color TV would just display it as B&W TV out of the box. In addition, black and white receivers could take the Y′ signal and ignore the U- and V-color signals, making Y′UV backward-compatible with all existing black-and-white equipment, input and output. If the color-TV standard wouldn't have used color difference signals, it could mean a color TV would make funny colors out of a B&W broadcast or it would need additional circuitry to translate the B&W signal to color. It was necessary to assign a narrower bandwidth to the chrominance channel because there was no additional bandwidth available. If some of the luminance information arrived via the chrominance channel (as it would have if RB signals were used instead of differential UV signals), B&W resolution would have been compromised.


Conversion to/from RGB


SDTV with BT.470

Y′UV signals are typically created from
RGB The RGB color model is an additive color model in which the red, green and blue primary colors of light are added together in various ways to reproduce a broad array of colors. The name of the model comes from the initials of the three additi ...
(
red Red is the color at the long wavelength end of the visible spectrum of light, next to orange and opposite violet. It has a dominant wavelength of approximately 625–740 nanometres. It is a primary color in the RGB color model and a secondary ...
,
green Green is the color between cyan and yellow on the visible spectrum. It is evoked by light which has a dominant wavelength of roughly 495570 nm. In subtractive color systems, used in painting and color printing, it is created by a combin ...
and
blue Blue is one of the three primary colours in the RYB colour model (traditional colour theory), as well as in the RGB (additive) colour model. It lies between violet and cyan on the spectrum of visible light. The eye perceives blue when ob ...
) source. Weighted values of R, G, and B are summed to produce Y′, a measure of overall brightness or luminance. U and V are computed as scaled differences between Y′ and the B and R values. PAL (NTSC used
YIQ YIQ is the color space used by the analog NTSC color TV system, employed mainly in North and Central America, and Japan. ''I'' stands for ''in-phase'', while ''Q'' stands for ''quadrature'', referring to the components used in quadrature amplitud ...
, which is further rotated) standard defines the following constants, derived from BT.470 System M primaries and white point using SMPTE RP 177 (same constants called matrix coefficients were used later in BT.601, although it uses 1/2 instead of 0.436 and 0.615): :\begin W_R &= 0.299, \\ W_G &= 1 - W_R - W_B = 0.587, \\ W_B &= 0.114, \\ U_\text &= 0.436, \\ V_\text &= 0.615. \end PAL signals in Y′UV are computed from R'G'B' (only SECAM IV used linear RGB) as follows: :\begin Y' &= W_R R' + W_G G' + W_B B' = 0.299 R' + 0.587 G' + 0.114 B', \\ U &= U_\text \frac \approx 0.492(B' - Y'), \\ V &= V_\text \frac \approx 0.877(R' - Y'). \end The resulting ranges of Y′, U, and V respectively are
, 1 The comma is a punctuation mark that appears in several variants in different languages. It has the same shape as an apostrophe or single closing quotation mark () in many typefaces, but it differs from them in being placed on the baseline o ...
��''U''max, ''U''max and ��''V''max, ''V''max Inverting the above transformation converts Y′UV to RGB: :\begin R' &= Y' + V \frac = Y' + \frac = Y' + 1.14 V,\\ G' &= Y' - U \frac - V \frac \\ &= Y' - \frac - \frac = Y' - 0.395 U - 0.581 V, \\ B' &= Y' + U \frac = Y' + \frac = Y' + 2.033 U. \end Equivalently, substituting values for the constants and expressing them as
matrices Matrix most commonly refers to: * ''The Matrix'' (franchise), an American media franchise ** '' The Matrix'', a 1999 science-fiction action film ** "The Matrix", a fictional setting, a virtual reality environment, within ''The Matrix'' (franchi ...
gives these formulas for BT.470 System M (PAL): :\begin \begin Y' \\ U \\ V \end &= \begin 0.299 & 0.587 & 0.114 \\ -0.14713 & -0.28886 & 0.436 \\ 0.615 & -0.51499 & -0.10001 \end \begin R' \\ G' \\ B' \end, \\ \begin R' \\ G' \\ B' \end &= \begin 1 & 0 & 1.13983 \\ 1 & -0.39465 & -0.58060 \\ 1 & 2.03211 & 0 \end \begin Y' \\ U \\ V \end. \end For small values of Y' it is possible to get R, G, or B values that are negative so in practice we clamp the RGB results to the interval ,1or more correctly clamp inside the Y'CbCr. In BT.470 a mistake was made (because 0.115 was used instead of 0.114 for blue and 0.493 was the result instead of 0.492). In practice that did not affect the decoders because the approximation 1/2.03 was used.


HDTV with BT.709

For
HDTV High-definition television (HD or HDTV) describes a television system which provides a substantially higher image resolution than the previous generation of technologies. The term has been used since 1936; in more recent times, it refers to the g ...
the
ATSC Advanced Television Systems Committee (ATSC) standards are an American set of standards for digital television transmission over terrestrial, cable and satellite networks. It is largely a replacement for the analog NTSC standard and, like that ...
decided to change the basic values for WR and WB compared to the previously selected values in the SDTV system. For HDTV these values are provided by Rec. 709. This decision further impacted on the matrix for the Y′UV↔RGB conversion so that its member values are also slightly different. As a result, with SDTV and HDTV there are generally two distinct Y′UV representations possible for any RGB triple: a SDTV-Y′UV and a HDTV-Y′UV one. This means in detail that when directly converting between SDTV and HDTV, the luma (Y′) information is roughly the same but the representation of the chroma (U & V) channel information needs conversion. Still in coverage of the
CIE 1931 color space The CIE 1931 color spaces are the first defined quantitative links between distributions of wavelengths in the electromagnetic visible spectrum, and physiologically perceived colors in human color vision. The mathematical relationships that defin ...
the Rec. 709 color space is almost identical to Rec. 601 and covers 35.9%. In contrast to this UHDTV with Rec. 2020 covers a much larger area and thus its very own matrix was derived for YCbCr (no YUV/Y′UV, since decommissioning of analog TV). BT.709 defines these weight values: :\begin W_R &= 0.2126, \\ W_G &= 1 - W_R - W_B = 0.7152, \\ W_B &= 0.0722 \\ \end The U_ and V_ values are from above. The conversion matrices for analog form of BT.709 are these, but there is no evidence those were ever used in practice (instead only actually described form of BT.709 is used, the
YCbCr YCbCr, Y′CbCr, or Y Pb/Cb Pr/Cr, also written as 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-dif ...
form): :\begin \begin Y' \\ U \\ V \end &= \begin 0.2126 & 0.7152 & 0.0722 \\ -0.09991 & -0.33609 & 0.436 \\ 0.615 & -0.55861 & -0.05639 \end \begin R' \\ G' \\ B' \end \\ \begin R' \\ G' \\ B' \end &= \begin 1 & 0 & 1.28033 \\ 1 & -0.21482 & -0.38059 \\ 1 & 2.12798 & 0 \end \begin Y' \\ U \\ V \end \end


Notes

* The weights used to compute Y′ (top row of matrix) are identical to those used in the Y′IQ color space. * Equal values of red, green and blue (i.e. levels of gray) yield 0 for U and V. Black, RGB=(0, 0, 0), yields YUV=(0, 0, 0). White, RGB=(1, 1, 1), yields YUV=(1, 0, 0). * These formulas are traditionally used in analog televisions and equipment; digital equipment such as
HDTV High-definition television (HD or HDTV) describes a television system which provides a substantially higher image resolution than the previous generation of technologies. The term has been used since 1936; in more recent times, it refers to the g ...
and digital video cameras use Y′CbCr. ,1using the BT.709 matrix"> File:YUV plane 0.png, Y′ value of 0 File:YUV plane 0p5.png, Y′ value of 0.5 File:YUV plane 0p5 gamut.png, Y′ value of 0.5, with untruncated gamut shown by the center rectangle File:YUV plane 1.png, Y′ value of 1


Numerical approximations

Prior to the development of fast
SIMD Single instruction, multiple data (SIMD) is a type of parallel processing in Flynn's taxonomy. SIMD can be internal (part of the hardware design) and it can be directly accessible through an instruction set architecture (ISA), but it should ...
floating-point In computing, floating-point arithmetic (FP) is arithmetic that represents real numbers approximately, using an integer with a fixed precision, called the significand, scaled by an integer exponent of a fixed base. For example, 12.345 can be r ...
processors, most digital implementations of RGB → Y′UV used integer math, in particular
fixed-point Fixed point may refer to: * Fixed point (mathematics), a value that does not change under a given transformation * Fixed-point arithmetic, a manner of doing arithmetic on computers * Fixed point, a benchmark (surveying) The term benchmark, be ...
approximations. Approximation means that the precision of the used numbers (input data, output data and constant values) is limited, and thus a precision loss of typically about the last binary digit is accepted by whoever makes use of that option in typically a trade-off to improved computation speeds. In the following examples, the operator "a \gg b" denotes a right shift of ''a'' by ''b'' binary positions. For clarification the variables are using two index characters: "u" is used for the unsigned final representation, and "t" is used for the scaled-down intermediate value. The examples below are given for BT.601 only. The same principle can be used for doing functionally equivalent operations using values that do an acceptable match for data that follows the BT.709 or any other comparable standard. Y′ values are conventionally shifted and scaled to the range 6, 235(referred to as studio swing or "TV levels") rather than using the full range of
, 255 The comma is a punctuation mark that appears in several variants in different languages. It has the same shape as an apostrophe or single closing quotation mark () in many typefaces, but it differs from them in being placed on the baseline ...
(referred to as full swing or "PC levels"). This practice was standardized in SMPTE-125M in order to accommodate signal overshoots ("ringing") due to filtering. The value 235 accommodates a maximal black-to-white overshoot of 255 − 235 = 20, or 20 / (235 − 16) = 9.1%, which is slightly larger than the theoretical maximal overshoot (
Gibbs phenomenon In mathematics, the Gibbs phenomenon, discovered by Available on-line at:National Chiao Tung University: Open Course Ware: Hewitt & Hewitt, 1979. and rediscovered by , is the oscillatory behavior of the Fourier series of a piecewise continuous ...
) of about 8.9% of the maximal step. The toe-room is smaller, allowing only 16 / 219 = 7.3% overshoot, which is less than the theoretical maximal overshoot of 8.9%. This is 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, giving a studio range of 16–240 for U and V. (These ranges are important in video editing and production, since using the wrong range will result either in an image with "clipped" blacks and whites, or a low-contrast image.)


Studio swing for YCbCr BT.601

For getting the traditional "studio-swing" 8-bit representation of YCbCr for SDTV/BT.601 the following operations can be used: # Basic transform from 8-bit RGB to 16-bit values (Y′: unsigned, Cb/Cr: signed, matrix values got rounded so that the later-on desired Y′ range of 6..235and Cb/Cr range of 6..240is reached): #:\beginY' \\ Cb \\ Cr \end = \begin 66 & 129 & 25 \\ -38 & -74 & 112 \\ 112 & -94 & -18 \end \begin R \\ G \\ B \end. # Scale down (" >>8") to 8 bits with rounding ("+128") (Y′: unsigned, Cb/Cr: signed): #: \begin Y_t' &= (Y' + 128) \gg 8,\\ Cb_t &= (U + 128) \gg 8,\\ Cr_t &= (V + 128) \gg 8. \end # Add an offset to the values to eliminate any negative values (all results are 8-bit unsigned): #: \begin Y_u' &= Y_t' + 16,\\ Cb_u &= Cb_t + 128,\\ Cr_u &= Cr_t + 128. \end


Full swing for YCbCr BT.601

For getting a "full-swing" 8-bit representation of Y′CbCr for SDTV/BT.601 the following operations can be used: # Basic transform from 8-bit RGB to 16-bit values (Y′: unsigned, Cb/Cr: signed, matrix values got rounded so that the later-on desired Y′CbCr range of each ..255is reached whilst no overflow can happen): #:\beginY' \\ Cb \\ Cr \end = \begin 77 & 150 & 29 \\ -43 & -84 & 127 \\ 127 & -106 & -21 \end \begin R \\ G \\ B \end. # Scale down (">>8") to 8-bit values with rounding ("+128") (Y′: unsigned, Cb/Cr: signed): #: \begin Y_t' &= (Y' + 128) \gg 8,\\ Cb_t &= (Cb + 128) \gg 8,\\ Cr_t &= (Cr + 128) \gg 8. \end # Add an offset to the values to eliminate any negative values (all results are 8-bit unsigned): #: \begin Y_u' &= Y_t',\\ Cb_u &= Cb_t + 128,\\ Cr_u &= Cr_t + 128. \end


Luminance/chrominance systems in general

The primary advantage of luma/chroma systems such as Y′UV, and its relatives Y′IQ and
YDbDr YDbDr, sometimes written YDBDR, is the colour space used in the SECAM analog terrestrial colour television broadcasting standard (adopted in France and some countries of the former Eastern Bloc) and PAL-N (adopted in Argentina, Paraguay and Urug ...
, is that they remain compatible with black and white analog television (largely due to the work of
Georges Valensi M. Georges Valensi (1889–1980) was a French telecommunications engineer who, in 1938, invented and patented a method of transmitting color images via luma and chrominance so that they could be received on both color and black & white television s ...
). The Y′ channel saves 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 Bandwidth commonly refers to: * Bandwidth (signal processing) or ''analog bandwidth'', ''frequency bandwidth'', or ''radio bandwidth'', a measure of the width of a frequency range * Bandwidth (computing), the rate of data transfer, bit rate or thr ...
. The human eye has fairly little spatial sensitivity to color: the accuracy of the brightness information of the luminance channel has far more impact on the image detail discerned than that of the other two. Understanding this human shortcoming, standards such as
NTSC The first American standard for analog television broadcast was developed by National Television System Committee (NTSC)National Television System Committee (1951–1953), Report and Reports of Panel No. 11, 11-A, 12–19, with Some supplement ...
and
PAL Phase Alternating Line (PAL) is a colour encoding system for analogue television. It was one of three major analogue colour television standards, the others being NTSC and SECAM. In most countries it was broadcast at 625 lines, 50 fields ( ...
reduce the bandwidth of the chrominance channels considerably. (Bandwidth is in the temporal domain, but this translates into the spatial domain as the image is scanned out.) 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 than that for the luminance. Early versions of NTSC rapidly alternated between particular colors in identical image areas to make them appear adding up to each other to the human eye, while all modern analogue and even most digital video standards use chroma subsampling by recording a picture's color information at reduced resolution. Only half the horizontal resolution compared to the brightness information is kept (termed 4:2:2 chroma subsampling), and often the vertical resolution is also halved (giving 4:2:0). The 4:x:x standard was adopted due to the very earliest color NTSC standard which used a chroma subsampling of 4:1:1 (where the horizontal color resolution is quartered while the vertical is full resolution) so that the picture carried only a quarter as much color resolution compared to brightness resolution. Today, only high-end equipment processing uncompressed signals uses a chroma subsampling of 4:4:4 with identical resolution for both brightness and color information. 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 model conversion is
lossy In information technology, lossy compression or irreversible compression is the class of data compression methods that uses inexact approximations and partial data discarding to represent the content. These techniques are used to reduce data size ...
, particularly obvious in crosstalk from the luma to the chroma-carrying wire, and vice versa, in analogue equipment (including
RCA connector The RCA connector is a type of electrical connector commonly used to carry audio and video signals. The name ''RCA'' derives from the company Radio Corporation of America, which introduced the design in the 1930s. The connectors male plug and ...
s to transfer a digital signal, as all they carry is analogue composite video, which is either YUV, YIQ, or even CVBS). Furthermore, NTSC and PAL encoded color signals in a manner that causes high bandwidth chroma and luma signals to mix with each other in a bid to maintain backward compatibility with black and white television equipment, which results in
dot crawl Dot crawl is a visual defect of color analog video standards when signals are transmitted as composite video, as in terrestrial broadcast television. It consists of moving checkerboard patterns which appear along horizontal color transitions (ve ...
and cross color artifacts. 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 display technologies, attempts were made since the late 1970s to preserve more of the Y′UV signal while transferring images, such as
SCART SCART (also known as or , especially in France, 21-pin EuroSCART in marketing by Sharp in Asia, Euroconector in Spain, EuroAV or EXT, or EIA Multiport in the United States, as an EIA interface) is a French-originated standard and associated 2 ...
(1977) and
S-Video S-Video (also known as separate video, Y/C, and erroneously Super-Video ) is an analog video signal format that carries standard-definition video, typically at 525 lines or 625 lines. It encodes video luma and chrominance on two separate chan ...
(1987) connectors. Instead of Y′UV, Y′CbCr was used as the standard format for (digital) common
video compression In information theory, data compression, source coding, or bit-rate reduction is the process of encoding information using fewer bits than the original representation. Any particular compression is either lossy or lossless. Lossless compression ...
algorithms such as
MPEG-2 MPEG-2 (a.k.a. H.222/H.262 as was defined by the ITU) 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, ...
. Digital television and DVDs preserve their compressed video streams in the MPEG-2 format, which uses a fully defined Y′CbCr color space, although retaining the established process of chroma subsampling. The professional
CCIR 601 ITU-R Recommendation BT.601, more commonly known by the abbreviations Rec. 601 or BT.601 (or its former name CCIR 601) is a standard originally issued in 1982 by the CCIR (an organization, which has since been renamed as the Internatio ...
digital video format also uses Y′CbCr at the common chroma subsampling rate of 4:2:2, 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. 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). Furthermore, the range of colors and brightnesses (known as the color
gamut In color reproduction, including computer graphics and photography, the gamut, or color gamut , is a certain ''complete subset'' of colors. The most common usage refers to the subset of colors which can be accurately represented in a given circ ...
and color volume) of RGB (whether it be BT.601 or Rec.709) is far smaller than the range of colors and brightnesses allowed by Y′UV. This can be very important when converting from Y′UV (or Y′CbCr) to RGB, since the formulas above can produce "invalid" RGB values – i.e., values below 0% or very far above 100% of the range (e.g., outside the standard 16–235 luma range (and 16–240 chroma range) for TVs and HD content, or outside 0–255 for standard definition on PCs). Unless these values are dealt with they will usually be "clipped" (i.e., limited) to the valid range of the channel affected. This changes the hue of the color, which is very undesirable, so it is therefore often considered better to desaturate the offending colors such that they fall within the RGB gamut. Likewise, when RGB at a given bit depth is converted to YUV at the same bit depth, several RGB colors can become the same Y′UV color, resulting in information loss.


Relation with Y′CbCr

Y′UV is often used as a term for
YCbCr YCbCr, Y′CbCr, or Y Pb/Cb Pr/Cr, also written as 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-dif ...
. However, while related, they are different formats with different scale factors. Not scaled matrix is used in
Photo CD Photo CD is a system designed by Kodak for digitizing and saving photos onto a CD. Launched in 1991, the discs were designed to hold nearly 100 high quality images, scanned prints and slides using special proprietary encoding. Photo CDs are d ...
's PhotoYCC. U and V are bipolar signals which can be positive or negative, and are zero for greys, whereas YCbCr usually scales all channels to either the 16–235 range or the 0–255 range, which makes Cb and Cr unsigned quantities which are 128 for greys. Nevertheless, the relationship between them in the standard case is simple. In particular, the Y' channels of both are linearly related to each other, both Cb and U are related linearly to (B-Y), and both Cr and V are related linearly to (R-Y).


Types of sampling

To get a digital signal, Y′UV images can be
sampled Sample or samples may refer to: Base meaning * Sample (statistics), a subset of a population – complete data set * Sample (signal), a digital discrete sample of a continuous analog signal * Sample (material), a specimen or small quantity of so ...
in several different ways; see chroma subsampling.


Converting between Y′UV and RGB

RGB files are typically encoded in 8, 12, 16 or 24 bits per pixel. In these examples, we will assume 24 bits per pixel, which is written as RGB888. The standard byte format is: r0, g0, b0, r1, g1, b1, ... Y′UV files can be encoded in 12, 16 or 24 bits per pixel. The common formats are Y′UV444 (or YUV444), YUV411, Y′UV422 (or YUV422) and Y′UV420p (or YUV420). The apostrophe after the Y is often omitted, as is the "p" after YUV420p. In terms of actual file formats, YUV420 is the most common, as the data is more easily compressed, and the file extension is usually ".YUV". The relation between data rate and sampling (A:B:C) is defined by the ratio between Y to U and V channel. To convert from RGB to YUV or back, it is simplest to use RGB888 and YUV444. For YUV411, YUV422 and YUV420, the bytes need to be converted to YUV444 first. YUV444 3 bytes per pixel (12 bytes per 4 pixels) YUV422 4 bytes per 2 pixels (8 bytes per 4 pixels) YUV411 6 bytes per 4 pixels YUV420p 6 bytes per 4 pixels, reordered


Y′UV444 to RGB888 conversion

The function , G, B= Y′UV444toRGB888(Y′, U, V) converts Y′UV format to simple RGB format. The RGB conversion formulae 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 formulae shown below. For more details, please see the 4:2:0 format demonstration in the bottom section of this article. These formulae are based on the NTSC standard: :\begin Y' &= 0.299 R + 0.587 G + 0.114 B \\ U &= -0.147 R - 0.289 G + 0.436 B \\ V &= 0.615 R - 0.515 G - 0.100 B \end On older, non-
SIMD Single instruction, multiple data (SIMD) is a type of parallel processing in Flynn's taxonomy. SIMD can be internal (part of the hardware design) and it can be directly accessible through an instruction set architecture (ISA), but it should ...
architectures, floating point arithmetic is much slower than using fixed-point arithmetic, so an alternative formulation is: :\begin Y' &= ( ( 66 R + 129 G + 25 B + 128) \gg 8) + 16 \\ U &= ( ( -38 R - 74 G + 112 B + 128) \gg 8) + 128 \\ V &= ( ( 112 R - 94 G - 18 B + 128) \gg 8) + 128 \end For the conversion from Y'UV to RGB, using the coefficients c, d and e, and noting that []_0^ denotes clamping (graphics), clamping a value to the 8-bit range of 0 to 255, the following formulae provide the conversion from Y′UV to RGB (NTSC version): :\begin c &= Y' - 16 \\ d &= U - 128 \\ e &= V - 128 \end :\begin R &= 298 c + 409 e + 128) \gg 80^ \\ G &= 298 c - 100 d - 208 e + 128) \gg 80^ \\ B &= 298 c + 516 d + 128) \gg 80^ \end Note: The above formulae are actually implied for YCbCr. Though the term YUV is used here, YUV and YCbCr are not exactly the same in a strict manner. The ITU-R version of the formula is different, with \max(C_B) = \max(C_R) = 0.499 \mapsto \mathrm_, whereas \max(U) = 0.436 \mapsto 70_ and \max(V) = 0.615 \mapsto 70_ above: :\begin Y &= 0.299 R + 0.587 G + 0.114 B + 0 \\ C_B &= -0.169 R - 0.331 G + 0.499 B + 128 \\ C_R &= 0.499 R - 0.418 G - 0.0813 B + 128 \\ \\ R &= + 1.402 \times (C_R - 128)0^ \\ G &= - 0.344 \times (C_B - 128) - 0.714 \times (C_R - 128)0^ \\ B &= + 1.772 \times (C_B - 128)0^ \end Integer operation of ITU-R standard for YCbCr (8 bits per channel) to RGB888: :\begin C_R &= C_R - 128; \\ C_B &= C_B - 128; \\ R &= Y + C_R + (C_R\gg2) + (C_R\gg3) + (C_R\gg5) \\ G &= Y - ((C_B\gg2) + (C_B\gg4) + (C_B\gg5)) - ((C_R\gg1) + (C_R\gg3) + (C_R\gg4) + (C_R\gg5)) \\ B &= Y + C_B + (C_B\gg1) + (C_B\gg2) + (C_B\gg6) \end


Y′UV422 to RGB888 conversion

: 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 y1 = yuv v = yuv y2 = yuv :_ = \beginu & y_1 \\ v & y_2\end :_ = \beginy_1 & u & v\\y_2 & u & v\end : = M^ _ 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 with the values in an alternative order, e.g. for the
FourCC A FourCC ("four-character code") is a sequence of four bytes (typically ASCII) used to uniquely identify data formats. It originated from the OSType or ResType metadata system used in classic Mac OS and was adopted for the Amiga/Electronic Arts ...
format code YUY2. : Input: Read 4 bytes of Y′UV (y1, u, y2, v), (y1, y2, u, v) or (u, v, y1, y2) :_ = \beginy_1 & u \\ y_2 & v\end :_ = \beginy_1 & y_2 \\ u & v\end :_ = \beginu & v\\y_1 & y_2\end


Y′UV411 to RGB888 conversion

: Input: Read 6 bytes of Y′UV : Output: Writes 12 bytes of RGB // Extract YUV components u = yuv y1 = yuv y2 = yuv v = yuv y3 = yuv y4 = yuv rgb1 = Y′UV444toRGB888(y1, u, v); rgb2 = Y′UV444toRGB888(y2, u, v); rgb3 = Y′UV444toRGB888(y3, u, v); rgb4 = Y′UV444toRGB888(y4, u, v); :_ = \beginu & y_1 & y_2 \\ v & y_3 & y_4\end :_ = \beginy_1 & u & v\\y_2 & u & v\\y_3 & u & v\\y_4 & u & v\end So the result is we are getting 4 RGB pixels values (4*3 bytes) from 6 bytes. This means reducing the size of transferred data to half, with a loss of quality.


Y′UV420p (and Y′V12 or YV12) to RGB888 conversion

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


Y′UV420sp (NV21) to RGB conversion (Android)

This format (NV21) is the standard picture format on Android camera preview. YUV 4:2:0 planar image, with 8 bit Y samples, followed by interleaved V/U plane with 8bit 2x2 subsampled chroma samples.fourcc.com YUV pixel formas
/ref> C++ code used on Android to convert pixels of YUVImage: void YUVImage::yuv2rgb(uint8_t yValue, uint8_t uValue, uint8_t vValue, uint8_t *r, uint8_t *g, uint8_t *b) const


References


External links


Explanation of many different formats in the Y′UV family
* Poynton, Charles



MATLAB toolbox for color science computation and accurate color reproduction (by Jesus Malo and Maria Jose Luque, Universitat de Valencia). It includes CIE standard tristimulus colorimetry and transformations to a number of non-linear color appearance models (CIE Lab, CIE CAM, etc.). * Kohn, Mike
Y′UV422 to RGB using SSE/Assembly




for image and video processing �

between RGB, YUV, YCbCr and YPbPr
libyuv

pixfc-sse
– C library of SSE-optimized color format conversions

– Sample / Demo YUV/RGB video files in many YUV formats, help you for the testing.
hacktv
– library for analog TV transmission using
software-defined radio Software-defined radio (SDR) is a radio communication system where components that have been traditionally implemented in analog hardware (e.g. mixers, filters, amplifiers, modulators/demodulators, detectors, etc.) are instead implemented b ...
{{Color space Color space