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

Due: 2/7/2020

[As before, your answers should be in the form of an executable m-file, named "YourNameHW2.m" -- thus if your name were Kim Lee, your m-file would be named "KimLeeHW2.m". Please check that your file can actually be executed before submitting it. Upload your file to the course canvas site. If you want to add any commentary, use the comment character % to do so.]

Color Matching

The background for this homework is the lecture on early color vision. You may also find it useful to review (or learn about) projecting a point onto a line, in the first section of this page. (This set of slides may also be helpful.)

Section 1

Download colmatch.mat to a place where Octave can find it, and load it with the command

load("colmatch.mat");

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.

You'll remember that a "color-matching matrix" maps a test light onto the weights of basis lights that match it. In the lecture notes, we used the equation e = Ct, where 

t is an N x 1 column vector (the "test light"),
C is a 3 x N matrix (the "color-matching matrix"), and 
e
 is a 3 x 1 column vector (the weighting of the primary lights that match the test light).

Essentially we are projecting an N-dimensional space (here 31-dimensional) into a 3-dimensional linear subspace.

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 this vector to represent the 31-dimensional wavelength spectrum of a test 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, and look again at the section of the lecture notes under the heading New color-matching matrices from old). 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. (By spectral sensitivity, we mean the R vector of the section of the lecture notes on scotopic matching. Since R is only unique up to a scale factor, any scaled version of a correct answer is also a correct answer.)
  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?

Section 2 (optional/advanced)

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.