Chapter 12 Color Models and Color Applications Computer Graphics Chapter 12 Color Models and Color Applications
Outline Properties of Light Color Models Standard Primaries and the Chromaticity Diagram The RGB Color Model The YIQ and Related Color Models The CMY and CMYK Color Models The HSV Color Model The HLS Color Model Color Selection and Applications
Properties of Light What is light? The Electromagnetic Spectrum “light” = narrow frequency band of electromagnetic spectrum The Electromagnetic Spectrum Red: 3.8x1014 hertz Violet: 7.9x1014 hertz
Spectrum of Light Monochrome light can be described by frequency f and wavelength λ c = λ f (c = speed of light) Normally, a ray of light contains many different waves with individual frequencies The associated distribution of wavelength intensities per wavelength is referred to as the spectrum of a given ray or light source
The Human Eye
Psychological Characteristics of Color Dominant frequency (hue, color) Brightness (area under the curve), total light energy Purity (saturation), how close a light appear to be a pure spectral color, such as red Purity = ED − EW ED = dominant energy density EW = white light energy density Chromaticity, used to refer collectively to the two properties describing color characteristics: purity and dominant frequency
Intuitive Color Concepts Color mixing created by an artist Shades, tints and tones in scene can be produced by mixing color pigments (hues) with white and black pigments Shades Add black pigment to pure color The more black pigment, the darker the shade Tints Add white pigment to the original color Making it lighter as more white is added Tones Produced by adding both black and white pigments
Colorimetry (CM) CM is the branch of color science concerned with numerically specifying the color of a physically defined visual stimulus Stimuli with the same specification look alike under the same viewing conditions Stimuli that look alike have the same specification The numbers used are continuous functions of the physical parameters Colorimetry n. measuring of the intensity of color
CM Properties CM only considers the visual discriminability of physical beams of radiation Colors are an equivalence class of mutually indiscriminable beams Colors in this sense cannot be said to be “red”, “green” or any other “color name” Discriminability is decided before the brain comes into action - CM is not psychology
Color Matching Experiments Observers had to match a test light by combining three fixed primaries Goal: find the unique RGB coordinates for each stimulus
Tristimulus Values The values RQ, GQ and BQ for a stimulus Q that fulfill Q = RQ*R + GQ*G + BQ*B are called the tristimulus values of Q R = 700.0 nm G = 546.1 nm B = 435.8 nm
Negative Light in a CME if a match using only positive RGB values proved impossible, observers could simulate a subtraction of red from the match side by adding it to the test side
Color Models Method for explaining the properties or behavior of color within some particular context Combine the light from two or more sources with different dominant frequencies and vary the intensity of light to generate a range of additional colors Primary Colors 3 primaries are sufficient for most purposes Hues that we choose for the sources Color gamut is the set of all colors that we can produce from the primary colors Complementary color is two primary colors that produce white Red and Cyan, Green and Magenta, Blue and Yellow
Color-Matching Colors in the vicinity of 500 nm can be matched by subtracting an amount of red light from a combination of blue and green lights Thus, an RGB color monitor cannot display colors in the neighborhood of 500 nm
CIE XYZ Problem solution: XYZ color system Tristimulus system derived from RGB Based on 3 imaginary primaries All 3 primaries are outside the human visual gamut Only positive XYZ values can occur 1931 by CIE (Commission Internationale de l’Eclairage)
Transformation CIE RGB->XYZ Projective transformation specifically designed so that Y = V (luminous efficiency function) XYZ CIE RGB uses inverse matrix XYZ any RGB matrix is device dependent X = 0.723R + 0.273G + 0.166B Y = 0.265R + 0.717G + 0.008B Z = 0.000R + 0.008G + 0.824B
The XYZ Model CIE primitives is referred to as the XYZ model In XYZ color space, color C (λ) represented as C (λ) = (X, Y, Z) where X Y Z are calculated from the color-matching functions k = 683 lumens/watt I(λ) = spectral radiance f = color-matching function
The XYZ Model Normalized XYZ values Normalize the amounts of each primary against the sum X+Y+Z, which represent the total light energy where z = 1 - x - y, color can be represented with just x and y x and y called chromaticity value, it depend only on hue and purify Y is luminance
RGB vs. XYZ
The CIE Chromaticity Diagram A tongue-shape curve formed by plotting the normalized amounts x and y for colors in the visible spectrum Points along the curve are spectral color (pure color) Purple line, the line joining the red and violet spectral points Illuminant C, plotted for a white light source and used as a standard approximation for average daylight Spectral Colors C Illuminant Purple Line
The CIE Chromaticity Diagram Luminance values are not available because of normalization Colors with different luminance but same chromaticity map to the same point Usage of CIE chromaticity diagram Comparing color gamuts for different set of primaries Identifying complementary colors Determining purity and dominate wavelength for a given color Color gamuts Identify color gamuts on diagram as straight-line segments or polygon regions
The CIE Chromaticity Diagram Color gamuts All color along the straight line joining C1 and C2 can be obtained by mixing colors C1 and C2 Greater proportion of C1 is used, the resultant color is closer to C1 than C2 Color gamut for C3, C4, C5 generate colors inside or on edges No set of three primaries can be combined to generate all colors
The CIE Chromaticity Diagram Complementary colors Represented on the diagram as two points on opposite sides of C and collinear with C The distance of the two colors C1 and C2 to C determine the amount of each needed to produce white light
The CIE Chromaticity Diagram Dominant wavelength Draw a straight from C through color point to a spectral color on the curve, the spectral color is the dominant wavelength Special case: a point between C and a point on the purple line Cp, take the compliment Csp as dominant Purity For a point C1, the purity determined as the relative distance of C1 from C along the straight line joining C to Cs Purity ratio = dC1 / dCs
Complementary Colors Subtractive Additive Pair of complementary colors subYM Complementary Colors subCR Additive Blue is one-third Yellow (red+green) is two-thirds When blue and yellow light are added together, they produce white light Pair of complementary colors blue and yellow green and magenta red and cyan Subtractive Orange (between red and yellow)<>cyan-blue green-cyan<>magenta-red color addRG
The RGB Color Model Basic theory of RGB color model The tristimulus theory of vision It states that human eyes perceive color through the stimulation of three visual pigment of the cones of the retina Red, Green and Blue Model can be represented by the unit cube defined on R,G and B axes
The RGB Color Model An additive model, as with the XYZ color system Each color point within the unit cube can be represented as a weighted vector sum of the primary colors, using vectors R, G and B C(λ)=(R, G, B)=RR+GG+BB Chromaticity coordinates for the National Television System Committee (NTSC) standard RGB primaries
Subtractive RGB Colors Red Green Blue Yellow Cyan Magenta Black Yellow absorbs Blue Magenta absorbs Green Cyan absorbs Red White minus Blue minus Green = Red
The CMY and CMYK Color Models Color models for hard-copy devices, such as printers Produce a color picture by coating a paper with color pigments Obtain color patterns on the paper by reflected light, which is a subtractive process The CMY parameters A subtractive color model can be formed with the primary colors cyan, magenta and yellow Unit cube representation for the CMY model with white at origin
The CMY and CMYK Color Models Transformation between RGB and CMY color spaces Transformation matrix of conversion from RGB to CMY Transformation matrix of conversion from CMY to RGB
The YIQ and Related Color Models YIQ, NTSC color encoding for forming the composite video signal YIQ parameters Y, same as the Y complement in CIE XYZ color space, luminance Calculated Y from the RGB equations Y = 0.299 R + 0.587 G + 0.114 B Chromaticity information (hue and purity) is incorporated with I and Q parameters, respectively Calculated by subtracting the luminance from the red and blue components of color I = R – Y Q = B – Y Separate luminance or brightness from color, because we perceive brightness ranges better than color
The YIQ and Related Color Models (2) Transformation between RGB and YIQ color spaces Transformation matrix of conversion from RGB to YIQ Transformation matrix of conversion from YIQ to RGB Obtain from the inverse matrix of the RGB to YIQ conversion
The HSV Color Model Interface for selecting colors often use a color model based on intuitive concepts rather than a set of primary colors The HSV parameters Color parameters are hue (H), saturation (S) and value (V) Derived by relating the HSV parameters to the direction in the RGB cube Obtain a color hexagon by viewing the RGB cube along the diagonal from the white vertex to the origin
The HSV Color Model The HSV hexcone Hue is represented as an angle about the vertical axis ranging from 0 degree at red to 360 degree Saturation parameter is used to designate the purity of a color Value is measured along a vertical axis through center of hexcone
HSV Color Model Hexcone Color components: Hue (H) ∈ [0°, 360°] Saturation (S) ∈ [0, 1] Value (V) ∈ [0, 1]
HSV Color Definition Color definition Select hue, S=1, V=1 Add black pigments, i.e., decrease V Add white pigments, i.e., decrease S Cross section of the HSV hexcone showing regions for shades, tints, and tones
HSV Hue is the most obvious characteristic of a color Chroma is the purity of a color High chroma colors look rich and full Low chroma colors look dull and grayish Sometimes chroma is called saturation Value is the lightness or darkness of a color Sometimes light colors are called tints, and Dark colors are called shades
Transformation To move from RGB space to HSV space: Can we use a matrix? No, it’s non-linear.
The HSV Color Model Transformation between HSV and RGB color spaces Procedure for mapping RGB into HSV class rgbSpace {public: float r, g, b;}; class hlsSpace {public: float h, l, s;}; void hsvT0rgb (hlsSpace& hls, rgbSpace& rgb) { /* HLS and RGB values are in the range from 0 to 1.0 */ int k float aa, bb, cc, f; if ( s <= 0.0) r = g = b = v; /* Have gray scale if s = 0 */ else { if (h == 1.0) h = 0.0; h *= 6.0; k = floor (h); f = h - k; aa = v * (1.0 - s); bb = v * (1.0 - (s * f)); cc = v * (1.0 - (s * (1.0 - f))); switch (k) { case 0: r = v; g = cc; b = aa; break; case 1: r = bb; g = v; b = aa; break; case 2: r = aa; g = v; b = cc; break; case 3: r = aa; g = bb; b = v; break; case 4: r = cc; g = aa; b = v; break; case 5: r = v; g = aa; b = bb; break; }
The HSV Color Model Transformation between HSV and RGB color spaces Procedure for mapping HSV into RGB class rgbSpace {public: float r, g, b;}; class hlsSpace {public: float h, l, s;}; const float noHue = -1.0; inline float min(float a, float b) {return (a < b)? a : b;} inline float mab(float a, float b) {return (a > b)? a : b;} void rgbTOhsv (rgbSpace rgb, hlsSpace hls) { float minRGB = min (r, min (g, b)), maxRGB = max (r, max (g, b)); float deltaRGB = maxRGB - minRGB; v = maxRGB; if (maxRGB != 0.0) s = deltaRGB / maxRGB; else s = 0.0; if (s <= 0.0) h = noHue; else { if (r == maxRGB) h = (g - b) / deltaRGB; else if (g == maxRGB) h = 2.0 + (b - r) / deltaRGB; else if (b == maxRGB) h = 4.0 + (r - g) / deltaRGB; h *= 60.0; if (h < 0.0) h += 360.0; h /= 360.0; }
The HLS Color Model HLS color model Another model based on intuitive color parameter Used by the Tektronix Corporation The color space has the double-cone representation Used hue (H), lightness (L) and saturation (S) as parameters
Color Model Summary Colorimetry: Device Color Systems: CIE XYZ: contains all visible colors Device Color Systems: RGB: additive device color space (monitors) CMYK: subtractive device color space (printers) YIQ: NTSC television (Y=luminance, I=R-Y, Q=B-Y) Color Ordering Systems: HSV, HLS: for user interfaces
Comparison RGB CMY CMYK YIQ HSV HSL
Color Selection and Applications Graphical package provide color capabilities in a way that aid users in making color selections For example, contain sliders and color wheels for RGB components instead of numerical values Color applications guidelines Displaying blue pattern next to a red pattern can cause eye fatigue Prevent by separating these color or by using colors from one-half or less of the color hexagon in the HSV model Smaller number of colors produces a better looking display Tints and shades tend to blend better than pure hues Gray or complement of one of the foreground color is usually best for background
How different are the colors of square A and square B? They are the same! Don’t believe me?
What color is this blue cube? How about this yellow cube?
Want to see it slower? What color is this How about this blue cube? yellow cube?
Even slower? How about this yellow cube? What color is this blue cube?
So what color is it? What color is this How about this blue cube? yellow cube? It’s gray!
Humans Only Perceive Relative Brightness
Cornsweet Illusion Cornsweet illusion. Left part of the picture seems to be darker than the right one. In fact they have the same brightness. The same image, but the edge in the middle is hidden. Left and right part of the image appear as the same color now.
Self-Animated Images
What happens when chickens see red? A company* that markets red contact lenses for chickens (at 20 cents a pair), points to medical studies showing that chickens wearing red-tinted contact lenses behave differently from birds that don't. They eat less, produce more and don't fight as much. This decreases aggressive tendencies and birds are less likely to peck at each other causing injury. A spokesman said the lenses will improve world egg-laying productivity by $600 million a year. (Perhaps everything looks red and they cannot distinguish combs, wattles, or blood. Or ...perhaps the chickens are happier because they're viewing the world through rose colored glasses.) Animalens Inc. of Wellesley, Mass If you don't believe this, read the facts! http://www.inc.com/magazine/19890501/5636.html
What did you see?
Bird in a Cage