LESSON

# Simulating the human color response

#### Share

#### Transcript

Let’s use MATLAB to simulate this whole color imaging process. To start with I am going to create again a short hand for the units of nanometers. I am going to create a spectral region of interest and I am going to pick a range from 350 nanometers, just above what we can see at the blue end of the spectrum. In steps of five nanometers and I am going to go all the way up to 800 nanometers. It is just a little bit beyond the visible end of the spectrum at the red end. Now I am going to load some data which is the spectrum of sunlight measured at the surface of the earth and we use the load spectrum function I am going to pass in the range of wavelengths I am interested in and I am going to ask for data from the file solar dot dat. So this has loaded the illumination spectrum of sunlight into the MATLAB workspace variable called E and I can plot E against lambda and have a look at that and there we have the spectrum wavelength across the bottom and intensity on the vertical axis.

Now I am going to load the reflectance information for the famous red brick. Going to use the load spectrum function again, passing the same range of wavelengths and the data comes from the file called red brick dot dat. Now I can display that in another figure, create figure two and now I am going to plot R against lambda and here we see the reflectance profile of the red brick and we can see that it reflects more red light then it does blue light.

Now I can compute the luminance of the red brick, and luminance is the product of the illuminance E and the reflectance and I use the dot star operator because what I am going to do is to multiply every element in E by the corresponding element in R. E and R we can see are both 91 by 1 element vectors, and the product L we can see is also 91 by 1 vector. Now I can plot illuminance and we can see it looks like this; so we have the incoming light, has got this spectrum. The light that has been reflected off the red brick has got a different spectrum, it has reflected more red and it has absorbed more blue and green.

Now, we are going to load the response of the human cones, I have also got that information in a file that is shipped with the toolbox. Again we pass in the spectral range we are interested in and we ask for data from the file cones dot dat.

Now there are three cones, so the cones data is a matrix that has got 91 rows and three columns, each column corresponds to one of the cones. Column one is the red cone, column two is the green cone and so on. I can plot the cone responses; again, I am going to plot them against lambda and here we see the three cone responses, see the blue cone, the green cone and the red cone.

Now what I am going to do is plot the response of the red cone to this incoming light. Now what I am going to do is to take the luminance and I am going to multiply it by the red channel of the cones response, so I am going to take all rows in the cone response in column one. That is the column that contains information about the red cone and here I have it, this is the response of the red cone to the incoming light from the red brick.

The cone responds to the integral of this function, the area underneath this curve, and we can see that this curve peaks up to about 0.18.

Let’s look at what it would be for the green cone, so I change that number there and now we see this is the response of the green cone. The peak is a little bit less, the peak is now about 0.11; it is not quite high. It is the area underneath; this curve is the response of the green cone when looking at the red brick.

Finally, the response of the blue cone is given by this and we can see that this is a fairly low response, the peak value is only 0.005.

Now I can compute a simple numerical approximation to the area underneath the curve using some rectangular integration. Use the MATLAB sum function and I am going to sum the luminance multiplied by the response in the first instance. I am going to do the response of the red cone and because it is a rectangular integration I should properly multiply by the wavelength step size, which is 5 nanometers, and this is the response of the red cone. The response of the green cone would be this. Almost half the value and the response of the blue cone is this much smaller value, about one eighth the response of the red cone to this luminance response.

We use MATLAB and some Toolbox functions to model the spectrum of a realistic light source, its modification after reflection from a colored object and the response of the cone cells to form a tristimulus response.

### Skill level

MATLAB experience

This content assumes an understanding of high school level mathematics; for example, trigonometry, algebra, calculus, physics (optics) and experience with MATLAB command line and programming, for example workspace, variables, arrays, types, functions and classes.