red_data = double(imread('R.ppm'));
green_data = double(imread('G.ppm'));
blue_data = double(imread('B.ppm'));

r = red_data(:,:,1);
g = green_data(:,:,2);
b = blue_data(:,:,3);

MTF_300d_r = zeros(13,1);
MTF_300d_g = zeros(13,1);
MTF_300d_b = zeros(13,1);
frequencies = [1 2 3 4 5 6 8 10 12 14 16 18 20];

%red first

%1 through 6
curr_region = r(695, 1190:1350);
MTF_300d_r(1) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = r(800, 1230:1312);
MTF_300d_r(2) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = r(926, 1240:1300);
MTF_300d_r(3) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = r(1052, 1250:1290);
MTF_300d_r(4) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = r(1178, 1255:1287);
MTF_300d_r(5) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = r(1280, 1257:1286);
MTF_300d_r(6) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));

%8 through 20
curr_region = r(802, 1780:1820);
MTF_300d_r(7) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = r(885, 1783:1817);
MTF_300d_r(8) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = r(967, 1786:1813);
MTF_300d_r(9) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = r(1050, 1788:1813);
MTF_300d_r(10) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = r(1132, 1790:1811);
MTF_300d_r(11) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = r(1215, 1791:1809);
MTF_300d_r(12) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = r(1280, 1792:1808);
MTF_300d_r(13) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));

%now green

%1 through 6
curr_region = g(677, 1190:1350);
MTF_300d_g(1) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = g(800, 1230:1312);
MTF_300d_g(2) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = g(926, 1240:1300);
MTF_300d_g(3) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = g(1052, 1250:1290);
MTF_300d_g(4) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = g(1178, 1255:1287);
MTF_300d_g(5) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = g(1280, 1257:1286);
MTF_300d_g(6) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));

%8 through 20
curr_region = g(802, 1780:1820);
MTF_300d_g(7) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = g(885, 1783:1817);
MTF_300d_g(8) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = g(967, 1786:1813);
MTF_300d_g(9) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = g(1050, 1788:1813);
MTF_300d_g(10) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = g(1132, 1790:1811);
MTF_300d_g(11) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = g(1205, 1791:1809);
MTF_300d_g(12) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = g(1280, 1792:1808);
MTF_300d_g(13) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));

%now blue

%1 through 6
curr_region = b(695, 1190:1350);
MTF_300d_b(1) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = b(800, 1230:1312);
MTF_300d_b(2) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = b(926, 1240:1300);
MTF_300d_b(3) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = b(1052, 1250:1290);
MTF_300d_b(4) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = b(1178, 1255:1287);
MTF_300d_b(5) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = b(1280, 1257:1286);
MTF_300d_b(6) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));

%8 through 20
curr_region = b(802, 1780:1820);
MTF_300d_b(7) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = b(885, 1783:1817);
MTF_300d_b(8) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = b(967, 1786:1813);
MTF_300d_b(9) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = b(1050, 1788:1813);
MTF_300d_b(10) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = b(1132, 1790:1811);
MTF_300d_b(11) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = b(1215, 1791:1809);
MTF_300d_b(12) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = b(1280, 1792:1808);
MTF_300d_b(13) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));