CIS 558 / Linguistics 525
Computer Analysis and Modeling of Biological Signals and Systems
Homework 2

Due: 2/15/2005

Color Matching

The background for this homework is the lecture on early color vision.

Load colmatch.mat in your Matlab environment. This file contains a number of matrices and vectors related to the color matching problems discussed in class. In particular, the variable P is an N x 3 matrix containing wavelength spectra for three basis lights (``primaries''), and the variable M is a 3 x N color-matching matrix corresponding to these primaries. For these problems N=31, corresponding to samples of the wavelength spectrum from 400nm to 700nm in increments of 10nm.

Set the variable light to a random vector of length 31 (help rand will give you information about how to do this). We will consider the components of this vector to be samples of the wavelength spectrum of a particular light.

  1. What combination of the three primaries in P will match the appearance of this randomly chosen test light? Compute the wavelength spectrum of the matching light (as a linear combination of the three primary wavelength spectra) and compare it to that of the test light. Why is it different?
  2. The variable Palt contains a different set of primary lights. Compute the corresponding matching matrix Malt (you will probably need to make use of the Matlab function inv which computes the inverse of a square matrix). Repeat the previous exercise with Palt and Malt. Is the matching spectrum different than in the previous exercise?
  3. The variable Phosphors contains the emission spectra of three standard color monitor phosphors. How would you choose the amplitude of each phosphor's emission in order to produce light on the monitor that matches light? Compute these amplitudes and demonstrate that the resulting mixture of phosphors does indeed produce the same tri-stimulus coordinates in the matching experiment.
  4. The variable M2 contains yet another matching matrix. This one was computed for a color-impaired individual, using the primaries in P. Compute the SVD of M2. How can you tell this individual is color-impaired? Assume that the individual has a standard color-blindness problem: they are missing one or more cone types. Derive the spectral sensitivity of the missing (or remaining) cone.
  5. The variable Cones contains approximate spectral sensitivities of t he three color photoreceptors (cones) in the human eye. They are ordered such that Cones(1,:) corresponds to the L (long-wavelength, or red) cones, Cones(2,:) the M (green) cones, and Cones(3,:) the S (blue) cones. Plot these using plot or try rgbplot, and compare to the cone sensitivity vector you derived in the previous problem. Which cone was missing from (or remaining in) your color-blind subject?
  6. Having just purchased a new house in Center City, you decide to paint the baseboard trim a new color. In particular, you'd like to have the trim match the color of your new couch (chartreuse, of course). You make a trip to the paint store, carrying with you a sample piece of fabric (complete with plastic slipcover). The store carries two brands of paint: ShabbyTint, which is mixed from three primary colors, and RichTone, which is mixed from a set of six primary colors. Naturally, the RichTone costs four times as much, so you decide to go with the ShabbyTint, and quickly pick a matching color from the ShabbyTint paint chart (the store mixes it for you, from the three ShabbyTint primaries).

    Load the file paint.mat into Matlab. This will define a few variables:


    1. Determine the mixture of ShabbyTint primaries that will match the sample you've taken to the paint store. Assume that paint-mixing is additive (it really isn't!). Plot the wavelength spectra of the sample and the paint (when viewed in the paint store) on the same plot (use the Matlab hold command to do this). Demonstrate that a paint mixed from this proportion of the three primaries will look just like the sample.
    2. You may now view these colors on your monitor. To do this, first download the MATLAB m-file showcols.m and place it where MATLAB (or Octave) can "see" it. Then create two column vectors of height 3, called rgb1 and rgb2 containing the monitor gun values (proportion of each phosphor) to be used to display a color matching the couch and the shabby paint mixture under fluorescent lighting. You should assume that the matrix Phosphors contains emission spectra that are correct for your monitor (this may not be true). Then call the function showcols(rgb1,rgb2).
    3. You take the paint home, and paint a small sample of baseboard. The next morning, when the sun comes up, you find to your horror that the baseboard doesn't match the couch at all. What happened? Show that the two colors really don't match when viewed under daylight. Render them on the screen using showcols to check this.
    4. What is the best (least-squares) combination of ShabbyTint primaries that you could have used to match the couch both in daylight and fluorescent light?
    5. What if you use the RichTone paint? Assess the quality of the best-matching mixture under both daylight and fluorescent light.

Further explorations

If you found this exercise easy, then you might want to look into some related issues in more depth. I've chosen three areas of work that happen to be done by other faculty at Penn: Dan Lee, Lawrence Saul and David Brainard.

I. At several points in this section of the course, we've pointed out a problem with linear models: they assume that negative numbers are perfectly good citizens of the world of values for the elements of vectors, while as a matter of physical fact they often are not. It makes no physical sense to think of turning the intensity of a light down below zero, into the range of negative intensities; nor can we mix a paint with a negative quantity of a selected pigment. In the lecture on early color vision and in this homework, we've been content to point out this problem and to invite you to ignore it. If you want to look into ways to solve similar problems realistically, imposing non-negativity constraints, take a look at this paper as a place to start. As you'll see, there can be other advantages to non-negativity!

II. Linear methods essentially depend on finding a new coordinate system to represent vectors, in which key properties are easier to see, or easier to manipulate, or otherwise more accessible. These methods are useful for two reasons: their mathematical foundations are simple, general and tractable; and many (aspects of) natural phenomena are linear, or approximately so, or can be viewed in a way that makes them so. Of course, there are many cases where such methods just don't apply. Often, however, a problem is locally linear even if its larger-scale structure is not even approximately linear. In this situation, fitting a piecewise linear model may be helpful, as this paper suggests. Other nonlinear methods have become popular recently.

III. We've only scratched the surface of the problem of color vision. Take a look at some of these papers to learn more, especially this one and this one.