Color Models and Color Applications Topics : Color Fundamentals Chromaticity Diagram Color Models What is Color ? To see color, three essential elements must be present: light, an illuminated object, and an observer. Visible Spectrum We perceive electromagnetic energy having wavelengths in the range 400-700 nm as visible light. Visible light is an electromagnetic wave in the range 400-700 nm Violet light Red light The color spectrum shows the range of wavelengths of energy that are visible to the human eye. Variation in wavelengths alters the colors we see. As Isaac Newton showed (1666) with his prisms, white light is a mixture of all the colors of the visible spectrum. Light and Color The frequency ( or mix of frequencies ) of the light determines the color. The amount of light(sheer quantity of photons ) is the intensity. Three independent quantities are used to describe any particular color. : hue, saturation, and lightness or brightness or intensity. The hue is determined by the dominant wavelength.(the apparent color of the light) When we call an object "red," we are referring to its hue. Hue is determined by the dominant wavelength. Light and Color The saturation of a color ranges from neutral to brilliant. The circle on the right is a more vivid red than the circle on the left although both have the same hue. The saturation is determined by the excitation purity , and depends on the amount of white light mixed with the hue. A pure hue is fully saturated, i.e. no white light mixed in. Hue and saturation together determine the chromaticity for a given color. Light and Color Lightness or brightness refers to the amount of light the color reflects or transmits. Finally, the intensity is determined by the actual amount of light, with more light corresponding to more intense colors ( the total light across all frequencies). Light that has a dominant frequency or set of frequencies is called chromatic. Achromatic light has no color - its only attribute is quantity or intensity. Greylevel is a measure of intensity. The intensity is determined by the energy, and is therefore a physical quantity. On the other hand, brightness is determined by the perception of the color, and is therefore psychological. Given equally intense blue and green, the blue is perceived as much darker than the green. Note also that our perception of intensity is nonlinear, with changes of normalised intensity from 0.1 to 0.11 and from 0.5 to 0.55 being perceived as equal changes in brightness. Color depends primarily on the reflectance properties of an object. We see those rays that are reflected, while others are absorbed. However, we also must consider the color of the light source, and the nature of human visual system. For example, an object that reflects both red and green will appear green when there is green but no red light illuminating it, and conversely it will appear red in the absence of green light. In pure white light, it will appear yellow (= red + green). Light and Color When light strikes an object, wavelengths may be reflected, absorbed or transmitted. Colorants can be mixed to control the wavelengths and colors we see. The photosensitive part of the eye is called the retina. The retina is largely composed of two types of cells, called rods and cones. Only the cones are responsible for color perception Light and Our Eyes The cones are sensitive to colored light and the rods are sensitive to achromatic light only. Light waves that reach the eye stimulate a visual process so complex it's not yet fully understood. Within the retina, cones respond to color hues and brightness. Rods sense only brightness. Three types of cones respond to wavelengths in ways that produce all the colors we see. The Fovea Cones are most densely packed within a region of the eye called the fovea. Primary colors ( Red, Green, Blue) The response of each type of cone as a function of the wavelength of the incident light is shown in figure. The peaks for each curve are at 440nm (blue), 545nm (green) and 580nm (red). Note that the last two actually peak in the yellow part of the spectrum. Figure : Spectral response curves for each cone type. The peaks for each curve are at 440nm (blue), 545nm (green) and 580nm (red). Light and Our Eyes •The color signal to the brain comes from the response of the 3 cones to the spectra being observed. That is, the signal consists of 3 numbers: R, G, and B •A color can be specified as the sum of three colors. So colors form a 3 dimensional vector space. •These three hues: red, green, and blue are called primary colors Standard observer Based upon psychophysical measurements, standard curves have been adopted by the CIE (Commission Internationale de l'Eclairage) as the sensitivity curves for the "typical" observer for the three "pigments" . These are not the actual pigment absorption characteristics found in the "standard" human retina but rather sensitivity curves derived from actual data . This function of wavelength is called the luminance-efficiency function of the eye. For an arbitrary homogeneous region in an image that has an intensity as a function of wavelength (color) given by I(), the three responses are called the tristimulus values: Color Matching In order to define the perceptual 3D space in a "standard" way, a set of experiments can (and have been) carried by having observers try and match color of a given wavelength, lambda, by mixing three other pure wavelengths, such as R=700nm, G=546nm, and B=436nm in the following example. Note that the phosphorus of color TVs and other CRTs do not emit pure red, green, or blue light of a single wavelength, as is the case for this experiment. We commonly see colors arrayed in two dimensions. This is a useful, but incomplete representation. Colors actually occupy a threedimensional space. • L*a*b Color Model Lightness is the third dimension that is not shown in color wheels often used in image editing software •A refined CIE model, named CIE L*a*b in 1976 •Luminance: L Chrominance: a -- ranges from green to red, b -ranges from blue to yellow Used by Photoshop CIE Chromaticity Diagram To measure and predict the appearance of a particular color, we need a way to link perception to numbers and formulas. Scientific color values were established earlier this century by the CIE group. CIE models for defining color space all rely on the same basic numbers. CIE Chromaticity Diagram In 1931, the CIE defined three standard primaries (X, Y, Z). The Y primary was intentionally chosen to be identical to the luminous-efficiency function of human eyes. C XX YY ZZ •The above figure shows the amounts of X, Y, Z needed to exactly reproduce any visible color. CIE Color Space In order to achieve a representation which uses only positive mixing coefficients, the CIE ("Commission Internationale d'Eclairage") defined three new hypothetical light sources, x, y, and z, which yield positive matching curves: If we are given a spectrum and wish to find the corresponding X, Y, and Z quantities, we can do so by integrating the product of the spectral power and each of the three matching curves over all wavelengths. The weights X,Y,Z form the three-dimensional CIE XYZ space, as shown below. CIE chromaticity coordinates In 1931, the Commission Internationale de l'Éclairage (CIE) defined three standard primaries, called X, Y and Z, that can be added to form all visible colors. The primary Y was chosen so that its color matching function exactly matches the luminous-efficiency function for the human eye, given by the sum of the three curves2. The chromaticity coordinates which describe the perceived color information are defined as: The red chromaticity coordinate is given by x and the green chromaticity coordinate by y. The tristimulus values are linear in I() and thus the absolute intensity information has been lost in the calculation of the chromaticity coordinates {x,y}. All color distributions, I(), that appear to an observer as having the same color will have the same chromaticity coordinates. Figure : The CIE Chromaticity Diagram showing all visible colors. x and y are the normalized amounts of the X and Y primaries present, and hence z = 1 - x - y gives the amount of the Z primary required. CIE Chromaticity Diagram Often it is convenient to work in a 2D color space. This is commonly done by projecting the 3D color space onto the plane X+Y+Z=1, yielding a CIE chromaticity diagram. The projection is defined as: Giving the chromaticity diagram shown on the right. CIE Chromaticity Diagram A complete description of a color is typically given with the three values x, y, and Y. The remaining CIE amounts are then calculated as : x X Y; y z Z Y y Figure : Mixing colors on the chromaticity diagram. All colors on the line IJ can be obtained by mixing colors I and J, and all colors in the triangle IJK can be obtained by mixing colors I, J and K. The formulas for converting from the tristimulus values (X,Y,Z) to the well-known CRT colors (R,G,B) and back are given by: As long as the position of a desired color (X,Y,Z) is inside the phosphor triangle in Figure , the values of R, G, and B as computed by eq. will be positive and can therefore be used to drive a CRT monitor. CIE Chromaticity Diagram •All visible colors are in a "horseshoe" shaped cone in the X-Y-Z space. Consider the plane X+Y+Z=1 and project it onto the X-Y plane, we get the CIE chromaticity diagram as below. Definitions: •Spectrophotometer :A device to measure the spectral energy distribution. It can therefore also provide the CIE xyz tristimulus values. •Illuminant C : The point C is plotted for a white-light source known as illuminant C •Complementary colors : If the two color sources combine to produce white light, they are referred to as complementary colors ( blue and yellow; red and cyan. For example, colors on segment CD are complementary to the colors on segment CB. Definitions: *dominant wavelength : The spectral color which can be mixed with white light in order to reproduce the desired color. color B in the above figure is the dominant wavelength for color A. * non-spectral colors : colors not having a dominant wavelength. For example, color E in the above figure. A color can be specified by its colorimetric values. A colorimeter is an instrument that measures color using numbers derived from CIE values. A spectrophotom eter is another instrument for measuring color. It samples wavelengths across the color spectrum •The gamut of colors is all colors that can be reproduced using the three primaries Measuring color allows us to compare the color gamut, or range of colors produced by different methods. We find that color transparency film produces a wide range of colors including some a monitor cannot display. Digital color printers and printing presses have different color gamuts. They can never capture all the colors in an original transparency, but they can simulate the appearance very successfully if color reproduction is understood and controlled. Color management software, described later, helps transform color from one gamut to another. Color Models Color models provide a standard way to specify a particular color, by defining a 3D coordinate system, and a subspace that contains all constructible colors within a particular model. Any color that can be specified using a model will correspond to a single point within the subspace it defines. Each color model is oriented towards either specific hardware (RGB,CMY,YIQ), or image processing applications (HSI). The RGB Color Cube The additive color model used for computer graphics is represented by the RGB color cube, where R, G, and B represent the colors produced by red, green and blue phosphorus, respectively. The RGB Model This is an additive model, i.e. the colors present in the light add to form new colors, and is appropriate for the mixing of colored light for example. The image on the left of figure shows the additive mixing of red, green and blue primaries to form the three secondary colors yellow (red + green), cyan (blue + green) and magenta (red + blue), and white ((red + green + blue). The RGB model is used for color monitors and most video cameras. The figure on the left shows the additive mixing of red, green and blue primaries to form the three secondary colors yellow (red + green), cyan (blue + green) and magenta (red + blue), and white ((red + green + blue). The figure on the right shows the three subtractive primaries, and their pairwise combinations to form red, green and blue, and finally black by subtracting all three primaries from white. The RGB Color Cube The color cube sits within the CIE XYZ color space as follows. RGB Color Model for CRT Displays •CRT displays have three phosphors (RGB) which produce a combination of wavelengths when excited with electrons. CMY Color Model •Cyan, Magenta, and Yellow (CMY) are complementary colors of RGB. They can be used as Subtractive Primaries. •CMY model is mostly used in printing devices where the color pigments on the paper absorb certain colors (e.g., no red light reflected from cyan ink). Conversion between RGB and CMY •Convert White from (1, 1, 1) in RGB to (0, 0, 0) in CMY: •Sometimes, an alternative CMYK model (K stands for Black) is used in color printing (e.g., to produce darker black than simply mixing CMY). K := min (C, M, Y), C := C - K, M := M - K, Y := Y - K. Color Gamuts The chromaticity diagram can be used to compare the "gamuts" of various possible output devices (i.e., monitors and printers). Note that a color printer cannot reproduce all the colors visible on a color monitor Color Printing Green paper is green because it reflects green and absorbs other wavelengths. The following table summarizes the properties of the four primary types of printing ink. dye color absorbs reflects cyan red blue and green magenta green blue and red yellow blue red and green black all none To produce blue, one would mix cyan and magenta inks, as they both reflect blue while each absorbing one of green and red. Unfortunately, inks also interact in non-linear ways. This makes the process of converting a given monitor color to an equivalent printer color a challenging problem. Black ink is used to ensure that a high quality black can always be printed, and is often referred to as to K. Printers thus use a CMYK color model. Color Conversion To convert from one color gamut to another is a simple procedure. Each phosphor color can be represented by a combination of the CIE XYZ primaries, yielding the following transformation from RGB to CIE XYZ: The transformation yields the color on monitor 2 which is equivalent to a given color on monitor 1. Conversion to-and-from printer gamuts is difficult. A first approximation is as follows: C=1-R M=1-G Y=1–B The fourth color, K, can be used to replace equal amounts of CMY: K = min(C,M,Y) C' = C - K M' = M - K Y' = Y - K The YIQ (luminance-inphase-quadrature) model is a recoding of RGB for color television, and is a very important model for color image processing. The importance of luminance was discussed . The conversion from RGB to YIQ is given by: The luminance (Y) component contains all the information required for black and white television, and captures our perception of the relative brightness of particular colors. That we perceive green as much lighter than red, and red lighter than blue, is indicated by their respective weights of 0.587, 0.299 and 0.114 in the first row of the conversion matrix above. These weights should be used when converting a color image to greyscale if you want the perception of brightness to remain the same. The YIQ Model Figure: Image (a) shows a color test pattern, consisting of horizontal stripes of black, blue, green, cyan, red, magenta and yellow, a color ramp with constant intensity, maximal saturation, and hue changing linearly from red through green to blue, and a greyscale ramp from black to white. Image (b) shows the intensity for image (a). Note how much detail is lost. Image (c) shows the luminance. This third image accurately reflects the brightness variations perceived in the original image The HSI Model As mentioned above, color may be specified by the three quantities hue, saturation and intensity. This is the HSI model, and the entire space of colors that may be specified in this way is shown in figure . The HSI Model Figure : The HSI model, showing the HSI solid on the left, and the HSI triangle on the right, formed by taking a horizontal slice through the HSI solid at a particular intensity. Hue is measured from red, and saturation is given by distance from the axis. Colors on the surface of the solid are fully saturated, i.e. pure colors, and the greyscale spectrum is on the axis of the solid. For these colors, hue is undefined. Conversion between the RGB model and the HSI model is quite complicated. See HSICalc.java See ShowColors2.java Comparison of Three Color Gamuts •The gamut of colors is all colors that can be reproduced using the three primaries •The Lab gamut covers all colors in visible spectrum •The RGB gamut is smaller, hence certain visible colors (e.g. pure yellow, pure cyan) cannot be seen on monitors •The CMYK gamut is the smallest (but not a straight subset of the RGB gamut) True-Color Frame Buffers •Each pixel requires at least 3 bytes. One byte for each primary color. •Sometimes combined with a look-up table per primary •Each pixel can be one of 2^24 colors Indexed-Color Frame Buffers •Each pixel uses one byte •Each byte is an index into a color map •If the color map is not updated synchronously then Color-map flashing may occurs. •Color-map Animations •Each pixel may be one of 2^24 colors, but only 256 color be displayed at a time High-Color Frame Buffers •Popular PC/(SVGA) standard •Each pixel can be one of 2^15 colors •Can exhibit worse quantization effects than Indexed-color Specialty Frame Buffers •Non-RGB color models (YUV) or 4-2-2 •True color plus an Overlay •Older 4-bit per pixel models [I,R,G,B] •True-color with a lookup-per-color component Conclusions color - in computer graphics we use an additive color model * colors are represented using Red, Green, and Blue components * the CRT has a mechanism for displaying these three components * a 24-bit RGB color model uses 8 bits for each of red, green, and blue * the human eye processes color similarly - there are three kinds of cones * RGB color model combines color and intensity information in each component * HSI color model separates intensity from color information * java.awt.Color provides a method to do conversion * HSICalc.java * documentation for RGBtoHSB( ) is online