Full color image along with its R, G, and B componentsAdditive color mixing demonstrated with CD covers used asbeam splittersA diagram demonstrating additive color with RGB
The main purpose of the RGB color model is for the sensing, representation, and display of images in electronic systems, such as televisions and computers, though it has also been used in conventionalphotography andcolored lighting. Before theelectronic age, the RGB color model already had a solid theory behind it, based inhuman perception of colors.
RGB is adevice-dependent color model: different devices detect or reproduce a given RGB value differently, since the color elements (such asphosphors ordyes) and their response to the individual red, green, and blue levels vary from manufacturer to manufacturer, or even in the same device over time. Thus an RGB value does not define the samecolor across devices without some kind ofcolor management.[3][4]
Additive color mixing: projectingprimary color lights on a white surface shows secondary colors where two overlap; the combination of all three primaries in equal intensities makes white.
To form a color with RGB, three light beams (one red, one green, and one blue) must be superimposed (for example by emission from a black screen or by reflection from a white screen). Each of the three beams is called acomponent of that color, and each of them can have an arbitrary intensity, from fully off to fully on, in the mixture.
The RGB color model isadditive in the sense that if light beams of differing color (frequency) are superposed in space their light spectra adds up, wavelength for wavelength, to make up a resulting, total spectrum.[5][6] This is in contrast to thesubtractive color model, particularly theCMY Color Model, which applies to paints, inks, dyes and other substances whose color depends onreflecting certain components (frequencies) of the light under which they are seen.
In the additive model, if the resulting spectrum, e.g. of superposing three colors, is flat, white color is perceived by the human eye upon direct incidence on the retina. This is in stark contrast to the subtractive model, where the perceived resulting spectrum is what reflecting surfaces, such asdyed surfaces, emit. A dye filters out all colors but its own; two blended dyes filter out all colors but the common color component between them, e.g. green as the common component between yellow and cyan, red as the common component between magenta and yellow, and blue-violet as the common component between magenta and cyan. There is no common color component among magenta, cyan and yellow, thus rendering a spectrum of zero intensity:black.
Zero intensity for each component gives the darkest color (no light, considered theblack), and full intensity of each gives awhite; thequality of this white depends on the nature of the primary light sources, but if they are properly balanced, the result is a neutral white matching the system'swhite point. When the intensities for all the components are the same, the result is a shade ofgray, darker, or lighter depending on the intensity. When the intensities are different, the result is a colorizedhue, more or lesssaturated depending on the difference of the strongest and weakest of the intensities of the primary colors employed.
When one of the components has the strongest intensity, the color is a hue near this primary color (red-ish, green-ish, or blue-ish), and when two components have the same strongest intensity, then the color is a hue of asecondary color (a shade ofcyan,magenta, oryellow). A secondary color is formed by the sum of two primary colors of equal intensity: cyan is green+blue, magenta is blue+red, and yellow is red+green. Every secondary color is the complement of one primary color: cyan complements red, magenta complements green, and yellow complements blue. When all the primary colors are mixed in equal intensities, the result is white.
The RGBcolor model itself does not define what is meant byred,green, andblue colorimetrically, and so the results of mixing them are not specified as absolute, but relative to the primary colors. When the exactchromaticities of the red, green, and blue primaries are defined, the color model then becomes anabsolute color space, such assRGB orAdobe RGB.
Physical principles for the choice of red, green, and blue
A set of primary colors, such as thesRGB primaries, define acolor triangle; only colors within this triangle can be reproduced by mixing the primary colors. Colors outside the color triangle are therefore shown here as gray. The primaries and theD65white point of sRGB are shown. The background figure is theCIE xy chromaticity diagram.
The choice of primary colors is related to the physiology of thehuman eye; good primaries are stimuli that maximize the difference between the responses of thecone cells of the human retina to light of differentwavelengths, and that thereby make a largecolor triangle.[7]
The normal three kinds of light-sensitivephotoreceptor cells in the human eye (cone cells) respond most to yellow (long wavelength or L), green (medium or M), and violet (short or S) light (peak wavelengths near 570 nm, 540 nm and 440 nm, respectively[7]). The difference in the signals received from the three kinds allows the brain to differentiate a widegamut of different colors, while being most sensitive (overall) to yellowish-green light and to differences between hues in the green-to-orange region.
As an example, suppose that light in theorange range of wavelengths (approximately 577 nm to 597 nm) enters the eye and strikes the retina. Light of these wavelengths would activate both the medium and long wavelength cones of the retina, but not equally—the long-wavelength cells will respond more. The difference in the response can be detected by the brain, and this difference is the basis of our perception of orange. Thus, the orange appearance of an object results from light from the object entering our eye and stimulating the different cones simultaneously but to different degrees.
Use of the three primary colors is not sufficient to reproduceall colors; only colors within the color triangle defined by thechromaticities of the primaries can be reproduced by additive mixing of non-negative amounts of those colors of light.[7][page needed]
The first permanent color photograph, taken byThomas Sutton in 1861 usingJames Clerk Maxwell's proposed method of three filters, specifically red, green, and violet-blue
The first experiments with RGB in earlycolor photography were made in 1861 by Maxwell himself, and involved the process of combining three color-filtered separate takes.[1] To reproduce the color photograph, three matching projections over a screen in a dark room were necessary.
The additive RGB model and variants such as orange–green–violet were also used in theAutochrome Lumière color plates and other screen-plate technologies such as theJoly color screen and thePaget process in the early twentieth century. Color photography by taking three separate plates was used by other pioneers, such as the RussianSergey Prokudin-Gorsky in the period 1909 through 1915.[8] Such methods lasted until about 1960 using the expensive and extremely complextri-color carbroAutotype process.[9]
When employed, the reproduction of prints from three-plate photos was done by dyes or pigments using the complementaryCMY model, by simply using the negative plates of the filtered takes: reverse red gives the cyan plate, and so on.
Before the development of practical electronic TV, there were patents on mechanically scanned color systems as early as 1889 inRussia. Thecolor TV pioneerJohn Logie Baird demonstrated the world's first RGB color transmission in 1928, and also the world's first color broadcast in 1938, inLondon. In his experiments, scanning and display were done mechanically by spinning colorized wheels.[10][11]
TheColumbia Broadcasting System (CBS) began an experimental RGBfield-sequential color system in 1940. Images were scanned electrically, but the system still used a moving part: the transparent RGB color wheel rotating at above 1,200 rpm in synchronism with the vertical scan. The camera and thecathode-ray tube (CRT) were bothmonochromatic. Color was provided by color wheels in the camera and the receiver.[12][13][14] More recently, color wheels have been used in field-sequential projection TV receivers based on the Texas Instruments monochrome DLP imager.
The modern RGBshadow mask technology for color CRT displays was patented by Werner Flechsig in Germany in 1938.[15]
Personal computers of the late 1970s and early 1980s, such as theApple II andVIC-20, usecomposite video. TheCommodore 64 and theAtari 8-bit computers useS-Video derivatives.IBM introduced a 16-color scheme (4 bits—1 bit each for red, green, blue, and intensity) with theColor Graphics Adapter (CGA) for itsIBM PC in 1981, later improved with theEnhanced Graphics Adapter (EGA) in 1984. The first manufacturer of atruecolor graphics card for PCs (the TARGA) wasTruevision in 1987, but it was not until the arrival of theVideo Graphics Array (VGA) in 1987 that RGB became popular, mainly due to theanalog signals in the connection between the adapter and themonitor which allowed a very wide range of RGB colors. Actually, it had to wait a few more years because the original VGA cards were palette-driven just like EGA, although with more freedom than VGA, but because the VGA connectors were analog, later variants of VGA (made by various manufacturers under the informal name Super VGA) eventually added true-color. In 1992, magazines heavily advertised true-color Super VGA hardware.
Cutaway rendering of a color CRT:1. Electron guns2. Electron beams3. Focusing coils4. Deflection coils5. Anode connection6. Mask for separating beams for red, green, and blue part of displayed image7. Phosphor layer with red, green, and blue zones8. Close-up of the phosphor-coated inner side of the screenColor wheel with RGB pixels of the colorsRGBphosphor dots in aCRT monitorRGBsub-pixels in an LCD TV (on the right: an orange and a blue color; on the left: a close-up)
One common application of the RGB color model is the display of colors on acathode-ray tube (CRT),liquid-crystal display (LCD),plasma display, ororganic light emitting diode (OLED) display such as a television, a computer's monitor, or a large scale screen. Eachpixel on the screen is built by driving three small and very close but still separated RGB light sources. At common viewing distance, the separate sources are indistinguishable, which the eye interprets as a given solid color. All the pixels together arranged in the rectangular screen surface conforms the color image.
Duringdigital image processing each pixel can be represented in thecomputer memory or interface hardware (for example, agraphics card) asbinary values for the red, green, and blue color components. When properly managed, these values are converted into intensities or voltages viagamma correction to correct the inherent nonlinearity of some devices, such that the intended intensities are reproduced on the display.
TheQuattron released by Sharp uses RGB color and adds yellow as a sub-pixel, supposedly allowing an increase in the number of available colors.
RGB is also the term referring to a type ofcomponent video signal used in thevideo electronics industry. It consists of three signals—red, green, and blue—carried on three separate cables/pins. RGB signal formats are often based on modified versions of the RS-170 and RS-343 standards for monochrome video. This type of video signal is widely used in Europe since it is the best quality signal that can be carried on the standardSCART connector.[16][17] This signal is known asRGBS (4BNC/RCA terminated cables exist as well), but it is directly compatible withRGBHV used for computer monitors (usually carried on 15-pin cables terminated with 15-pinD-sub or 5 BNC connectors), which carries separate horizontal and vertical sync signals.
Outside Europe, RGB is not very popular as a video signal format; S-Video takes that spot in most non-European regions. However, almost all computer monitors around the world use RGB.
Aframebuffer is a digital device for computers which stores data in the so-calledvideo memory (comprising an array ofVideo RAM or similarchips). This data goes either to threedigital-to-analog converters (DACs) (for analog monitors), one per primary color or directly to digital monitors. Driven bysoftware, theCPU (or other specialized chips) write the appropriatebytes into the video memory to define the image. Modern systems encode pixel color values by devoting 8 bits to each of the R, G, and B components. RGB information can be either carried directly by the pixel bits themselves or provided by a separatecolor look-up table (CLUT) ifindexed color graphic modes are used.
A CLUT is a specializedRAM that stores R, G, and B values that define specific colors. Each color has its own address (index)—consider it as a descriptive reference number that provides that specific color when the image needs it. The content of the CLUT is much like a palette of colors. Image data that uses indexed color specifies addresses within the CLUT to provide the required R, G, and B values for each specific pixel, one pixel at a time. Of course, before displaying, the CLUT has to be loaded with R, G, and B values that define the palette of colors required for each image to be rendered. Some video applications store such palettes inPAL files (Age of Empires game, for example, uses over half-a-dozen[18]) and can combine CLUTs on screen.
RGB24 and RGB32
This indirect scheme restricts the number of available colors in an image CLUT—typically 256-cubed (8 bits in threecolor channels with values of 0–255)—although each color in the RGB24 CLUT table has only 8 bits representing 256 codes for each of the R, G, and B primaries, making 16,777,216 possible colors. However, the advantage is that an indexed-color image file can be significantly smaller than it would be with only 8 bits per pixel for each primary.
Modern storage, however, is far less costly, greatly reducing the need to minimize image file size. By using an appropriate combination of red, green, and blue intensities, many colors can be displayed. Current typicaldisplay adapters use up to24 bits of information for each pixel: 8-bit per component multiplied by three components (see theNumeric representations section below (24 bits = 2563, each primary value of 8 bits with values of 0–255). With this system, 16,777,216 (2563 or 224) discrete combinations of R, G, and B values are allowed, providing millions of different (though not necessarily distinguishable) hue, saturation andlightness shades. Increased shading has been implemented in various ways, some formats such as.png and.tga files among others using a fourthgrayscale color channel as a masking layer, often calledRGB32.
For images with a modest range of brightnesses from the darkest to the lightest, 8 bits per primary color provides good-quality images, but extreme images require more bits per primary color as well as the advanced display technology. For more information seeHigh Dynamic Range (HDR) imaging.
In classic CRT devices, the brightness of a given point over thefluorescent screen due to the impact of acceleratedelectrons is not proportional to the voltages applied to theelectron gun control grids, but to an expansive function of that voltage. The amount of this deviation is known as itsgamma value (), the argument for apower law function, which closely describes this behavior. A linear response is given by a gamma value of 1.0, but actual CRT nonlinearities have a gamma value around 2.0 to 2.5.
Similarly, the intensity of the output on TV and computer display devices is not directly proportional to the R, G, and B applied electric signals (or file data values which drive them through digital-to-analog converters). On a typical standard 2.2-gamma CRT display, an input intensity RGB value of (0.5, 0.5, 0.5) only outputs about 22% of full brightness (1.0, 1.0, 1.0), instead of 50%.[19] To obtain the correct response, agamma correction is used in encoding the image data, and possibly further corrections as part of thecolor calibration process of the device. Gamma affectsblack-and-white TV as well as color. In standard color TV, broadcast signals are gamma corrected.
TheBayer filter arrangement of color filters on the pixel array of a digital image sensor
In colortelevision and video cameras manufactured before the 1990s, the incoming light was separated byprisms and filters into the three RGB primary colors feeding each color into a separatevideo camera tube (orpickup tube). These tubes are a type of cathode-ray tube, not to be confused with that of CRT displays.
With the arrival of commercially viablecharge-coupled device (CCD) technology in the 1980s, first, the pickup tubes were replaced with this kind of sensor. Later, higher scale integration electronics was applied (mainly bySony), simplifying and even removing the intermediate optics, thereby reducing the size of homevideo cameras and eventually leading to the development of fullcamcorders. Currentwebcams andmobile phones with cameras are the most miniaturized commercial forms of such technology.
Photographicdigital cameras that use aCMOS or CCDimage sensor often operate with some variation of the RGB model. In aBayer filter arrangement, green is given twice as many detectors as red and blue (ratio 1:2:1) in order to achieve higherluminance resolution thanchrominance resolution. The sensor has a grid of red, green, and blue detectors arranged so that the first row is RGRGRGRG, the next is GBGBGBGB, and that sequence is repeated in subsequent rows. For every channel, missing pixels are obtained byinterpolation in thedemosaicing process to build up the complete image. Also, other processes used to be applied in order to map the camera RGB measurements into a standard color space as sRGB.
In computing, animage scanner is a device that optically scans images (printed text, handwriting, or an object) and converts it to a digital image which is transferred to a computer. Among other formats, flat, drum and film scanners exist, and most of them support RGB color. They can be considered the successors of earlytelephotography input devices, which were able to send consecutivescan lines asanalogamplitude modulation signals through standard telephonic lines to appropriate receivers; such systems were in use inpress since the 1920s to the mid-1990s. Color telephotographs were sent as three separated RGB filtered images consecutively.
Currently available scanners typically use CCD orcontact image sensor (CIS) as the image sensor, whereas older drum scanners use aphotomultiplier tube as the image sensor. Early color film scanners used ahalogen lamp and a three-color filter wheel, so three exposures were needed to scan a single color image. Due to heating problems, the worst of them being the potential destruction of the scanned film, this technology was later replaced by non-heating light sources such as colorLEDs.
A typical RGB color selector. Eachslider ranges from 0 to 255.
Hexadecimal 8-bit RGB representations of the main 125 colors
A color in the RGB color model is described by indicating how much of each of the red, green, and blue is included. The color is expressed as an RGB triplet (r,g,b), each component of which can vary from zero to a defined maximum value. If all the components are at zero the result is black; if all are at maximum, the result is the brightest representable white.
These ranges may be quantified in several different ways:
From 0 to 1, with any fractional value in between. This representation is used in theoretical analyses, and in systems that usefloating point representations.
Each color component value can also be written as apercentage, from 0% to 100%.
In computers, the component values are often stored asunsigned integer numbers in the range 0 to 255, the range that a single 8-bitbyte can offer. These are often represented as either decimal orhexadecimal numbers.
High-end digital image equipment are often able to deal with larger integer ranges for each primary color, such as 0..1023 (10 bits), 0..65535 (16 bits) or even larger, by extending the 24 bits (three 8-bit values) to32-bit,48-bit, or64-bit units (more or less independent from the particular computer'sword size).
For example, brightest saturatedred is written in the different RGB notations as:
Notation
RGB triplet
Arithmetic
(1.0, 0.0, 0.0)
Percentage
(100%, 0%, 0%)
Digital 8-bit per channel
(255, 0, 0) #FF0000 (hexadecimal)
Digital 12-bit per channel
(4095, 0, 0) #FFF000000
Digital 16-bit per channel
(65535, 0, 0) #FFFF00000000
Digital 24-bit per channel
(16777215, 0, 0) #FFFFFF000000000000
Digital 32-bit per channel
(4294967295, 0, 0) #FFFFFFFF0000000000000000
In many environments, the component values within the ranges are not managed as linear (that is, the numbers are nonlinearly related to the intensities that they represent), as in digital cameras and TV broadcasting and receiving due to gamma correction, for example.[20] Linear and nonlinear transformations are often dealt with via digital image processing. Representations with only 8 bits per component are considered sufficient ifgamma correction is used.[21]
Following is the mathematical relationship between RGB space to HSI space (hue, saturation, and intensity:HSI color space):
The RGB color model is one of the most common ways to encode color in computing, and several differentdigital representations are in use. The main characteristic of all of them is thequantization of the possible values per component (technically asample) by using onlyinteger numbers within some range, usually from 0 to some power of two minus one (2n − 1) to fit them into some bit groupings. Encodings of 1, 2, 4, 5, 8, and 16 bits per color are commonly found; the total number of bits used for an RGB color is typically called thecolor depth.
The RGB color model mapped to a cube. The horizontal x-axis as red values increasing to the left, y-axis as blue increasing to the lower right and the vertical z-axis as green increasing towards the top. The origin, black is the vertex hidden from view.
Since colors are usually defined by three components, not only in the RGB model, but also in other color models such asCIELAB andY'UV, among others, then athree-dimensionalvolume is described by treating the component values as ordinaryCartesian coordinates in aEuclidean space. For the RGB model, this is represented by a cube using non-negative values within a 0–1 range, assigning black to the origin at the vertex (0, 0, 0), and with increasing intensity values running along the three axes up to white at the vertex (1, 1, 1), diagonally opposite black.
An RGB triplet (r,g,b) represents the three-dimensional coordinate of the point of the given color within the cube or its faces or along its edges. This approach allows computations of thecolor similarity of two given RGB colors by simply calculating thedistance between them: the shorter the distance, the higher the similarity. Out-of-gamut computations can also be performed this way.
Initially, the limited color depth of most video hardware led to a limited color palette of 216 RGB colors, defined by the Netscape Color Cube. Theweb-safe color palette consists of the 216 (63) combinations of red, green, and blue where each color can take one of six values (inhexadecimal): #00, #33, #66, #99, #CC or #FF (based on the 0 to 255 range for each value discussed above). These hexadecimal values = 0, 51, 102, 153, 204, 255 in decimal, which = 0%, 20%, 40%, 60%, 80%, 100% in terms of intensity. This seems fine for splitting up 216 colors into a cube of dimension 6. However, lacking gamma correction, the perceived intensity on a standard 2.5 gamma CRT / LCD is only: 0%, 2%, 10%, 28%, 57%, 100%. See the actual web safe color palette for a visual confirmation that the majority of the colors produced are very dark.[22]
With the predominance of 24-bit displays, the use of the full 16.7 million colors of the HTML RGB color code no longer poses problems for most viewers. ThesRGB color space (adevice-independent color space[23]) forHTML was formally adopted as an Internet standard in HTML 3.2,[24][25] though it had been in use for some time before that. All images and colors are interpreted as being sRGB (unless another color space is specified) and all modern displays can display this color space (with color management being built in into browsers[26][27] or operating systems[28]).
where # equals the proportion of red, green, and blue respectively. This syntax can be used after such selectors as "background-color:" or (for text) "color:".
Wide gamut color is possible in modernCSS,[29] being supported by all major browsers since 2023.[30][31][32]
For example, a color on theDCI-P3 color space can be indicated as:
color(display-p3 # # #)
where # equals the proportion of red, green, and blue in 0.0 to 1.0 respectively.
Proper reproduction of colors, especially in professional environments, requires color management of all the devices involved in the production process, many of them using RGB. Color management results in several transparent conversions between device-independent (sRGB,XYZ,L*a*b*)[23] and device-dependentcolor spaces (RGB and others, as CMYK for color printing) during a typical production cycle, in order to ensure color consistency throughout the process. Along with the creative processing, such interventions on digital images can damage the color accuracy and image detail, especially where the gamut is reduced. Professional digital devices and software tools allow for 48 bpp (bits per pixel) images to be manipulated (16 bits per channel), to minimize any such damage.
Allluminance–chrominance formats used in the different TV and video standards such asYIQ forNTSC,YUV forPAL,YDBDR forSECAM, andYPBPR for component video use color difference signals, by which RGB color images can be encoded for broadcasting/recording and later decoded into RGB again to display them. These intermediate formats were needed for compatibility with pre-existent black-and-white TV formats. Also, those color difference signals need lower databandwidth compared to full RGB signals.
Similarly, current high-efficiency digital color imagedata compression schemes such asJPEG andMPEG store RGB color internally inYCBCR format, a digital luminance–chrominance format based on YPBPR. The use of YCBCR also allows computers to performlossysubsampling with the chrominance channels (typically to 4:2:2 or 4:1:1 ratios), which reduces the resultant file size.
^Fairman, Hugh S.; Brill, Michael H.; Hemmendinger, Henry (February 1997). "How the CIE 1931 color-matching functions were derived from Wright-Guild data".Color Research & Application.22 (1):11–23.doi:10.1002/(SICI)1520-6378(199702)22:1<11::AID-COL4>3.0.CO;2-7.The first of the resolutions offered to the 1931 meeting defined the color-matching functions of the soon-to-be-adopted standard observer in terms of Guild's spectral primaries centered on wavelengths 435.8, 546.1, and 700nm. Guild approached the problem from the viewpoint of a standardization engineer. In his mind, the adopted primaries had to be producible with national-standardizing-laboratory accuracy. The first two wavelengths were mercury excitation lines, and the last named wavelength occurred at a location in the human vision system where the hue of spectral lights was unchanging with wavelength. Slight inaccuracy in production of the wavelength of this spectral primary in a visual colorimeter, it was reasoned, would introduce no error at all.
^For a side-by-side comparison of proper colors next to their equivalent lacking proper gamma correction, seeDoucette, Matthew (15 March 2006)."Color List".Xona Games.
^King, James C."Why Color Management?"(PDF). International Color Consortium. Retrieved2008-04-16.The two PCS's in the ICC system are CIE-XYZ and CIELAB