function [r, g, b, exposure_times] = linearity_300d()

numPhotos = 7; %7 shutter speeds were used for this data set

shortest_exposure = double(1/200); %Shortest exposure time used was 1/200 s
for i=1:numPhotos,
    exposure_times(i) = shortest_exposure*2^(i-1);
end;

r = zeros(numPhotos,1);
g = zeros(numPhotos,1);
b = zeros(numPhotos,1);

for i=0:(numPhotos-1),
    num = num2str(9925+i); %The first file happens to be numbered 9925
    name = strcat('CRW_', num, '.ppm'); %Filenames are of the form: CRW_XXXX.ppm
    data = double(imread(name, 'ppm')); %Files came out of dcraw - already in PPM format
    r(i+1) = mean(mean(data(:,:,1)));
    g(i+1) = mean(mean(data(:,:,2)));
    b(i+1) = mean(mean(data(:,:,3)));
end;

r = r./(2^16);
g = g./(2^16);
b = b./(2^16);

figure;
hold on;
plot(exposure_times, r, 'r');
plot(exposure_times, g, 'g');
plot(exposure_times, b, 'b');
title('Verification of Canon EOS 300D Linearity');
xlabel('Exposure time (s)');
ylabel('Normalized sensor output');