CS 6650, Fall 2002

Program 2: Spectral Color

David Cline

 

 

Create an RGB image from the spectral image:

L(x,y,lambda) = (y/n_y) delta(lambda - (420(x/n_x) + 380))

where x and y are pixel locations, lambda is wavelength in nanometers, and delta is the dirac delta function.

use n_x = n_y = 512.

 

Note on L:

 

L produces a spectral image such that each column of the image has a single non-zero wavelength.  The intensity of light at that wavelength varies in the y direction from 0 at the bottom of the image to 1 at the top of the image.  In other words, L(x,y,lambda) has a single wavelength (420(x/n_x)+380) with intensity (y/n_y).

 

 

L(x,y,lambda)

 

 

k=0.1

k=0.3

k=1.0

 

k=3.0

k=10.0

k=30.0

 

Tone mapping of the spectral image L() is achieved as follows:

 

Start with spectrum = L(x,y,lambda)

Convert spectrum to XYZ tristimulus value using tristimulus response curves.

Find xyz:  x = X / (X+Y+Z).  y = Y / (X+Y+Z).  z = Z / (X+Y+Z)

Convert Y to y0:  y0 = (k*Y) / (1+k*Y)

Convert X and Z to x0 and z0:  x0 = x*y0 / y.  z0 = (1-x-y) * y0 / y.

Convert (x0, y0, z0) to (r, g, b) by

 

[R]   [ 2.5623 –1.1161 –0.3962] [x0]

[G] = [-1.0215  1.9778  0.0437] [y0]

[B]   [ 0.0752 –0.2562  1.1810] [z0]

 

The (r,g,b) value is then clamped to be between 0 and 1.  The table above shows the effect of changing the values of k.

 

 

3 samples

4 samples

 

6 samples

9 samples

20 samples

50 samples

3 samples

4 samples

6 samples

9 samples

20 samples

50 samples

 

Although L produces a continuous spectral range, I sample the spectrum in discrete bins.  I tried 2 different sampling techniques.  The first was to simply place a spectral sample in the bin most closely matching its wavelength.  The second idea was to use a weighted average over the two closest bins.  The results of this experiment for various numbers of bins are shown in the table above.