cs358 Lecture Notes Week 7, Thursday COLOR!!! How does the light that enters our eyes get translated into the perception of color? How can we produce images that elicit the color perception we want? How can we use color to convey quantitative information? ----- Visible light is EM radiation at wavelengths between 400 nm and 700 nm. If light enters our eyes that contains only one wavelength, we perceive it as one of the "spectral colors," a.k.a. the colors of the rainbow. 400 = violet 420 indigo 440 = blue 550 = green 600 yellow 650 orange 700 = red This mapping is pretty much arbitrary, but seems to be universal. There are many colors, including purple and brown, that cannot be created with a single frequency of light. They are mixtures of different colors. Mixtures of light ----------------- Most of the time there are many colors entering our eyes simultaneously. If the amount of light is roughly uniformly distributed across the spectrum, we perceive shades of gray (from black in the absence of light to white at the point where our sensors are saturated). As the shape of the distribution changes, it becomes more difficult to predict how we will perceive it. Two interesting questions: 1) given a spectrum, can we predict how it will be perceived? 2) given a color perception, how many different spectra can generate it? Question 1 ---------- How is a spectrum perceived? As far as I can find, there is no general answer, except for certain special cases. a) Spectral color + white If there is a single dominant frequency, plus a uniform distribution with lower energy (white light), we perceive the "hue" that corresponds to the dominant frequency, with "saturation" that depends on how much white light there is. b) Tricolor stimuli Physiologically, we know that there are three color sensors in our eyes. Each responds to different wavelengths of light. At each wavelength, we know how much each cone is stimulated. (aside -- our perception of blue is much weaker than our perception of the other colors. It takes much more blue light to yield the same amount of stimulus) For a given spectrum of light (mixture of various wavelengths), we can compute how much each cone is stimulated. (multiply the spectrum by the response curve wavelength-wise and then integrate the result). Tristimulus theory of color: any spectral input that yields the same stimulus values for the three cones will yield the same perceived color! That answers question #2. 2) given a color perception, how many different spectra can generate it? There are infinitely many spectra that can produce identical color perceptions -- they are called metamers. And leads to Question #3: what is the simplest way to generate light that will yield a given color perception? Possibility #1: variable-wavelength light source. Could generate all of the spectral colors. Turns out to be hard from an engineering POV. Possibility #2: many single-wavelength light sources very close together Each source is responsible for a range of the spectrum. Could generate a reasonable match for any given spectrum. Also hard from an engineering POV. Possibility #3: three single-wavelength sources very close together. Each wavelength corresponds to a peak in the cone response curve. blue = 438.1 green = 546.1 red = 700.0 4) How do we generate a given color using only three light sources? a) figure out how much the given color stimulates each cone b) stimulate each cone that much Problem: the response curves do overlap a little, so even a pure blue signal also stimulates the red and green cones Alternative: Display a spectral color on one side and a mixture of three colors on the other. Turn the knobs until the colors match. Generate a table that shows how much R, G and B to use for each spectral color. (Figure 2) This works for non-spectral colors, too. Unfortunately, not all colors can be generated! Not even all the spectral colors. In some cases, you have to have a "negative" amount of red light (meaning that you have to add red to the target color). Limitations of the tricolor model --------------------------------- 1) it is possible to choose three fixed-spectrum light sources that can generate any spectral color. Commission Internationale de l'Eclairage (CIE) colors known as X, Y, and Z Even they cannot generate all non-spectral colors. 2) There aren't any simple mechanical devices that generate X Y and Z -- we usually have to settle for whatever colors we can generate easily. 3) most arbitrary choices of three colors will yield a limited range (gamut) of colors RGB space --------- There are phospors that generate red, green and blue colors similar to the colors our cones particularly like. (although they are not single-wavelength sources) That's how computer monitors work. Each pixel is made up of three colored dots very close together. Most often the computer controls the color of each pixel using three bytes (24 bits per pixel). One byte = 256 different levels. 0 = off, 255 = full strength Some colors are obvious R G B white 255 255 255 black 0 0 0 red 255 0 0 green 0 255 0 blue 0 0 255 Some more interesting ones cyan 0 255 255 magenta 255 0 255 yellow 255 255 0 These values are often written in hexadecimal. FFFF00 is yellow. http://eies.njit.edu/~kevin/rgb.txt.html One of many mappings from color names to RGB values Cyan is the complement of red in the sense that they add up to white. RGB space is generally pretty confusing. Most people have no idea how to combine lights to make colors. That's because we're used to subtractive combination, not additive combination. Lots of programs force users to specify RGB values despite the fact that they don't have a clue how. PIGMENTS, INKS, and MONITORS Here's some material I lifted from http://www.humboldt1.com/~color/UC5.html Additive Color (RGB) The primary colors in light however, are red, green and blue. This color model is called Additive Color, because it begins with black and adds light gradually to eventually create white. This theory states that adding all of the pure primaries together creates white light. A color wheel for additive color shows that mixing the primaries still creates secondary colors, however they are quite different from the pigment color wheel. Equal amounts of red light mixed with green light creates yellow, green mixed blue creates cyan, and blue mixed with red creates magenta. The remaining colors in the visible spectrum are created by combining unequal amounts of red, green and blue. Additive color is what is used for computer monitors, televisions, and is what our eyes see in nature. Pigment Color: The traditional color wheel for painters has twelve colors, three primary colors, three secondary colors, and six tertiary colors. The primary colors for pigments are red, blue and yellow. Mixing the primariy colors creates the secondary colors. Red mixed with blue creates violet, red mixed with yellow creates orange, and yellow mixed with blue creates green. Mixing the primary colors with the secondary colors creates the tertiary colors; red-violet, red-orange, yellow-orange, yellow-green, blue-green, and blue violet. Pigments are greedy eaters. Red paint has the ability to absorb blue and green. Blue paint has the ability to absorb red and green. Mixing them should produce black. Actually, it produces a complicated spectrum of everything else that we perceive as purple. Secondary and tertiary colors are non-spectral. Pigment mixing is generally a messy business that does not lend itself to automation. Subtractive Color (CMYK) The offset printing proceess produces realistic looking full color photographs by using only four colors. To understand printing, we must begin with the white sheet of paper that that reflects white light (RGB). In order to see colors on the sheet, we must subtract (absorb) portions of the red, green and blue light so the remaining light reflects the desired color. When blue ink is printed, we see it as blue because it is absorbing red and green light. So in this color model we begin with white, and gradually subtract reflected light to create black. Interestingly enough, the primary colors for subtractive color are the secondary colors in the additive color model; cyan, magenta and yellow. In theory, the combination of these three colors should create black, but due to the limitations of ink pigments, a fourth color, black, is added to give the photographs realistic looking shadows and true blacks. The inks used for color printing are selective eaters. Cyan eats only red. Magenta eats only green. Yellow eats only blue. They are transparent, so they reflect everything else. When you stack them up on a white piece of paper, you can carefully substract one color at a time, leaving what you want. In theory, CMY should absorb all color and produce black. Actually, it produces a murky non-spectral color. That's why black ink is used in addition. Achromatic colors ----------------- When we get equal stimulus of all three cones, we perceive shades of gray. The amount of stimulus determines the shade of gray. (0,0,0) is black (255,255,255) is white in theory, (128,128,128) should appear halfway in between. In practice, most monitors produce light in a way that is not proportional to the RGB value. Midpoint colors are much darker than they should be (like 18% instead of 50%). You can compensate for this effect by amplifying the middle values. This is called gamma correction. http://www.vtiscan.com/~rwb/gamma.html An excellent page about gamma correction. If you do it carefully, you can get a sequence of RGB values that correspond to equal distances in perceptual space. This is called a linearized gray scale. COLOR SCALES ------------ http://www.cs.uml.edu/~agee/press/ColorCenter/ColorCenter.htm Haim Levkowitz's page Contains RGB values for a variety of color scales, and a couple of Applets that let you check out the scales. Includes a linearized gray scale. Studies have shown that LGS is one of the best scales for presenting visual data. People are able to discern features without being distracted by artifacts. Magenta scales are also good, and prettier than gray. Rainbow scales are popular, but people don't really have a good sense for the order. Heated metal scales are pretty good (black->red->yellow->white). Blue to white and blue to yellow are pretty, but not great for human eyes. Haim's optimal color scale black brown green blue white (any ideas why that works?) For more info... ------------- http://www.ergogero.com/FAQ/cfaqhome.html Contains tons of info about color!