From: <Saved by Windows Internet Explorer 7>
Subject: 
Date: Tue, 11 Dec 2007 15:45:55 -0800
MIME-Version: 1.0
Content-Type: text/html;
	charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://www.stanford.edu/class/ee263/matlab/color_perception.m
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 6.00.6000.16544" name=3DGENERATOR></HEAD>
<BODY><PRE>% Data for problem on color perception
close all;
clear all;

% This defines 20 discrete wavelengths
wavelength =3D 380:20:760; %(nm)

% Define the vectors of cone responsiveness
% Cone sensitivies for wavelengths in the visible range.  This data is=20
%  based on a graph on page 93 in Wandell's "Foundations of Vision"=20
L_cone_log =3D [-.9 -1.1 -1 -.8 -.7 -.6 -.5 -.4 -.3 -.25 -.3  -.4 -.8 =
-1.2 -1.6 -1.9 -2.4 -2.8 -3.6 -4];

M_cone_log =3D [-.8 -.85 -.85 -.6 -.5 -.4 -.3 -.2 -.1 -.15 -.3  -.7 -1.2 =
-1.7 -2.2 -2.9 -3.5 -4.2 -4.8 -5.5];

S_cone_log =3D [-.4 -.3 -.2 -.1 -.3 -.6 -1.2 -1.8 -2.5 -3.2  -4.1 -5 -6  =
-7 -8 -9 -10 -10.5 -11 -11.5];

% Raise everything to the 10 power to get the actual responsitivies. =20
% These vectors contain the coefficients l_i, m_i, and s_i described in =
the=20
% problem statement from shortest to longest wavelength.=20
L_coefficients =3D 10.^(L_cone_log);
M_coefficients =3D 10.^(M_cone_log);
S_coefficients =3D 10.^(S_cone_log);

% Plot the cone responsiveness.=20
figure(1);
plot(wavelength,L_cone_log,'-*')
hold;
plot(wavelength,M_cone_log,'--x');
plot(wavelength,S_cone_log,'-o')
xlabel('Light Wavelength (nm)');
ylabel('Log Relative Sensitivity');
legend('L cones', 'M cones', 'S cones');
title('Approximate Human Cone Sensitivities');
grid;



% Spectral Power Distribution of phosphors from shortest to longest =
wavelength
B_phosphor =3D [30 35 45 75 90 100 90 75 45 35 30 26 23 21 20 19 18 17 =
16 15];
G_phosphor =3D [21 23 26 30 35 45 75 90 100 90 75 45 35 30 26 23 21 20 =
19 18];
R_phosphor =3D [15 16 17 18 19 21 23 26 30 35 45 75 90 100 90 75 45 35 =
30 26];

%Plot the phosphors
figure(2);
plot(wavelength, B_phosphor,'-*');
hold;
plot(wavelength, G_phosphor,'-o');
plot(wavelength, R_phosphor,'--x');
grid;
xlabel('Light wavelength (nm)');
ylabel('Spectral Power Distribution of Phosphors');
legend('B phosphor', 'G phosphor', 'R phosphor');


% This is the spectral power distribution of the test light from the=20
% shortest wavelength to the longest.=20
test_light =3D [ 58.2792 42.3496 51.5512 33.3951 43.2907 22.5950 57.9807 =
76.0365  52.9823 64.0526 20.9069  37.9818  78.3329  68.0846 46.1095 =
56.7829 79.4211 5.9183  60.2869  5.0269]';

%Plot the test light
figure(3);
plot(wavelength, test_light, '-*');
grid;
xlabel('Light wavelength (nm)');
ylabel('Spectral Power Distribution of Test Light');
title('Test light');

% Define approximate spectrums for sunlight and a tungsten bulb. =20
% The [powers are in order of increasing wavelength
tungsten =3D [ 20 30 40 50 60 70  80  90 100 110 120 130 140 150 160 170 =
180 190 200 210];
sunlight =3D [40 70 100 160 240 220  180 160 180 180 160 140 140 140 140 =
130 120 116 110 110];

%Plot the specturms
figure(4);
plot(wavelength,tungsten,'-*');
hold
plot(wavelength,sunlight,'-o');
xlabel('Light wavelength (nm)');
ylabel('Spectral Power Distributions');
legend('Tungsten','Sunlight');
grid;
</PRE></BODY></HTML>
