color. summary color is complex the human visual system is complex and very good at processing light...

33
Color

Upload: lillian-johns

Post on 29-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Color

Summary

• Color is complex

• The human visual system is complex and very good at processing light

• Together they comprise a system that we aren’t even close to understanding but utilize very effectively

Other Related Topics

And what good talk on color would dare to leave out these topics…

The GretagMacBethTM ColorChecker®

The JOBO Card

Gamma

• RGB values from a camera (for instance) are linear

• RGB values viewed on a monitor are non-linear

• Gamma correction is a non-linear pre-adjustment of the linear RGB values to match (or meet the expectations of) the non-linear human visual system when viewing a non-linear monitor

• Implemented as a look-up table

0.0 1.0

1.0

0.0

R’G’B’

RGB

Gamma Correction

Linear RGB from camera

Uncorrected Linear RGB on monitor

Corrected Linear RGB from camera

Corrected Linear RGB on monitor

Alpha

• In computer graphics, we often speak of 32-bit RGB

• The additional 8-bits is not another color basis, but rather a value called Alpha

• Alpha defines how colors combine with one another in an operation called Alpha Blending

Alpha Blending

• In 3D computer graphics objects naturally obscure other objects

• Depending on the make-up of the object in front– You may not see the object in back, the object

in front is opaque– You may only see the object in back, the object

in front is translucent– You may see some combination of both objects

Alpha Blending

• The specification of an objects opacity is done through alpha

• The basic formula is one of linear interpolation

• The alpha value of the object in back is ignored• In the event that we have multiple objects stacked,

then the z-buffer rendering performs this calculation in order, back to front

CACACAC backfrontfrontfrontbackfrontfrontAlphaBlend )1(),,(

Color Space Quantization

• There are times (used to be times?) when our hardware does not (did not?) support 224 (24-bit) colors

• The alternative is (was?) typically an 256 (8-bit) color palette system– This is what the GIF file format supports

• The question then arises as to which 256 colors we should choose

Scalar Quantization

• Create 256 uniformly spaced bins• Place actual colors into the closest bin• Simply put, divide the components (or just drop

low order bits)• Does not account for non-uniform distribution of

colors in a scene (and therefore doesn’t work very well)

• But it’s easy to implement

Color Space Quantization

• The popularity (populosity) algorithm prescribes that we select the 256 most frequently used colors in the scene we are displaying

• Create a histogram of all 224 possible colors

• Keep only the top 256

Popularity (Populosity) AlgorithmC

OU

NT

COLOR INDEX

Color Frequency Histogram

• Create color frequency histogram• Sort histogram by count• Keep the 256 colors with the largest counts• Convert all other scene colors to the closest kept color

Popularity (Populosity) Algorithm

• This algorithm works fine for a small amount of original scene colors (relative to the target number of colors)

• When the number of different colors in the original scene is much greater than the target number, the algorithm breaks down– Especially where small scene objects are

concerned

Median-Cut Algorithm

• Rather than just histogram and keep the most popular colors, the median-cut algorithm attempts to find colors that represent equal numbers of colors in the original scene– Map color pixels onto the color cube– Recursively split the cube into smaller cubes, attempting to keep

the number of pixels in each cube the same– The procedure ends when n (the target number of colors) cubes are

created– The centroids of the cubes are the retained colors– All other pixel colors in each cube are set to the cube centroid

color

Quantization

• But what happens when the number of available colors is only 2? (monochrome display device)

• Popularity and median-cut algorithms won’t produce suitable results in this scenario

Threshold

• If we merely select a threshold and set pixel values below it to black and above it to white we lose a lot of information

Threshold

• The human visual system is so good that we can still see the picture (in our minds) even though the data (taken in by the eyes) is minimal

Dither

• By replacing individual pixels with a pattern of binary values, the human visual system can be fooled into seeing shades

• The problem with pure thresholding is that all of the error ends up in the pixel being processed

• With dithering, we attempt do distribute the error to surrounding pixels

Floyd-Steinberg Dithering

For each pixeldisplay the closest available colorcompute error = actualColor – displayedColorspread error over (weighted addition) neighboring actual pixels to the right and below

7 * error16

1 * error16

5 * error16

3 * error16

Currentpixel

Floyd-Steinberg Dithering

• Again, the human visual system is so good that we can still see the picture (in our minds) even though the data (taken in by the eyes) is minimal

Dithering

• Other dithering techniques involve replacing pixels with patterns meant to approximate the amount of “ink” (intensity) on the page

• The downside of these approaches are that the display size is typically larger than the actual image

Chromatic Adaptation

• The human visual system interprets colors as being constant under varying illuminants– White looks white under fluorescent,

incandescent, daylight, etc. (well, most of the time)

• We would like to do this algorithmically– We don’t know exactly how the human visual

system achieves this goal

Chromatic Adaptation

• Using the XYZ color space (for whatever it is good for) requires knowledge of the ambient white point– e.g. D50, D65, etc.

– This is referred to as relative colorimetry

• Through some mathematical magic– Given an X1Y1Z1 point relative to a specific white point

– That point can be converted to an X2Y2Z2 point relative to a different white point

Chromatic Adaptation

• Thus, given an image taken under one light source, we can convert it to appear as though it was taken under a different light source

• This is the process known as Chromatic Adaptation

• There are various published ways to do this but the most widely used is Bradford Adaptation

Bradford Adaptation

ZYX

M

BB

GG

RR

MZYX

CAT

W

W

W

W

W

W

CAT

1

1

1

*

1

*

2

*

1

*

2

*

1

*

2

1

2

2

2

00

00

00

0296.10685.00389.0

0367.07135.17502.0

1614.02664.08951.0

M CAT

Bradford Transformation Matrix

Color Image Statistics

• All the obvious stuff– Count the number of unique colors– Count the number of “important” colors– Average red, green, blue– etc.

• All based on the color histogram

Color Histogram

• Not computationally feasible to create a linear histogram like we did for gray level images– Gray level images: 2n bins for an n-bit image– For a color image n=24 which 16,777,216 bins

• So we resort to other forms

Color Histogram

• 3D histogram– Display the distribution as points in a 3D cube

– Give the user tools to rotate the cube

• 2D histogram– 2D array where the vertical axis is one color and the

horizontal is another• Bins represent count of colors with those two component

values (third component is a wild card)

– Amounts to planar projections of the 3D histogram

Color Histogram

• Neither approach is easy to use

• Both require the user to develop a sense of what they are looking at

• Color is hard!

Plugins

• I’ve posted plugins for– Floyd-Steinberg Dither– RGB to HSV– RGB to HLS– RGB to YPbPr– Bradford Chromatic Adaptation Transformation

• This merely repeat the math on page 290 – it does not do any image manipulations (just wanted to prove that the book didn’t have any errors)

[a few selected]References

• How the Retina Works – Helga Kolb American Scientist, Volume 91

• Calculation From the Original Experimental Data of the CIE 1931 RGB Standard Observer Spectral Chromaticity Coordinates and Color Matching Functions – D.A. Broadbent University de Sherbrooke

• Eye, Brain, and Vision – David H. Hubel Scientific American Library 1988

• RGB Coordinates of the Macbeth ColorChecker – Danny Pascale www.babelcolor.com

• The RGB Code: The Mysteries of Color Revealed – Danny Pascale www.babelcolor.com