Introduction to Color
- This discussion is taken mainly from an older version of Computer Graphics by Hern and Baker.
- So far, we have just assumed the hardware people were right in giving us three "color" planes in the frame buffer
- 8 bits for red (0 to 255)
- 8 bits for green (0 to 255)
- 8 bits for blue (0 to 255)
- And bits for alpha.
- Which gives us a nice 32 bit data chunk.
- And 16 million colors (2^24)
- Other systems might allow more colors by providing more bits..
- For monitors this is not such an issue
- But on my monitor, 1680x1050 the maximum colors I could display is 1.7 million pixels.
- And three times that on all three monitors (5.2 million)
- So I could not display all 16 million colors if I wanted to.
- A medium range color laser printer prints 2400x800 dots per inch.
- Paper is 8x11 so that is 168 million dots (give or take)
- So generally in more comprehensive graphics packages
- We store color values between [0,1]
- And only scale them to the display device when it is time.
- Simply by multiplying the value of each component by the max value.
- The HTML canvas does not do this because HTML in general is aimed at display on monitors and the color representation suffices
- It uses the 32 bit color model.
- But when we get to OpenGL we will be using ranges of [0,1]
- We "see" light in the visible spectrum.
- This varies by person.
- But typically we can see wavelengths between 390 and 700 nm
- Or a frequency between 430 and 770 THz.
-
- A screen shot of a picture on wikipedia
- Some colors (like pink) are a mixture of two or more wavelengths.
- Apparently we all see colors slightly differently.
- And most humans can distinguish 400,000 different colors.
- Light
- Might contain all colors (or frequencies)
- (From britannica.com)
- Or might contain a subset of the frequencies (think blue light)
- when it strikes an object, some frequencies are reflected and some absorbed.
- So the reflected light will not contain all frequencies.
- For many distributions of light there will be a narrow band of high intensity at a single or small frequency.
- This is called the dominant wavelength or color or even hue.
- We also see a luminance or brightness of the light.
- This is a relative intensity of the light.
- The higher the intensity, the brighter the light.
- We also see a characteristic called purity or saturation.
- This describes how pure the light is.
- So in white light, no dominant frequency is present.
-
- Above, the energy distribution for white light, reproduced based on Baker and Hern.
-
- The energy distribution for an dominant frequency, again reproduced based on Baker and Hern.
- The energy of the dominate frequency is labeled Ed
- The energy of the other frequencies is labeled Ew
- Brightness is really the area under the curve.
- Saturation is the difference between Ed and Ew
- The larger the difference the more "pure" the color.
- If two different colored lights can be combined to form white light, these two colors are called complementary colors.
- The proper mixture of Cyan (#00FFFF) and Red (#FF0000) make white and are thus complementary
- The same is true for Magenta (#FF00FF) and Green (#00FF00).
- And many others.
- Color models typically select three dominate frequencies, called primary colors to represent all colors.
- No set of primary colors can produce all possible frequencies within the visible spectrum.
- You would need an infinite set to do this.
- But three are sufficient for most purposes.
- The International Commission on Illumination (CIE) established a model for describing colors.
- In 1931
- For three primary colors A,B, and C (remember these are frequencies)
- x = A/(A+B+C), y = B/(A+B+C) and z=C/(A+B+C)
- and x+y+z = 1.
- So z = 1-(x+y)
-
- A CIE chromacity diagram, from Wikipedia.
- Selecting any two points in this diagram as two colored light sources
- Any color on the line can be produced by proportionally mixing these colors.
- Any three points define a triangle which is equivalent to a selection of these three frequencies as primary colors.
- Points within the triangle are colors which can be produced with that selection of primary colors.
- Notice, not triangle can encompass all colors.
- Knowing the coordinates of the triangles allow users to compare the color range of different devices.
- A representation of the Color triangle for RGB from wikipedia.
-