red_data = double(nefRead('R.NEF'));
green_data = double(nefRead('G.NEF'));
blue_data = double(nefRead('B.NEF'));

%for simplicity, just use green channels
r = red_data(:,:,1);
g = (green_data(:,:,2)+green_data(:,:,4))/2;
b = blue_data(:,:,3);

MTF_d70_r = zeros(13,1);
MTF_d70_g = zeros(13,1);
MTF_d70_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(390, 618:682);
MTF_d70_r(1) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = r(440, 632:667);
MTF_d70_r(2) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = r(492, 637:662);
MTF_d70_r(3) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = r(544, 641:658);
MTF_d70_r(4) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = r(595, 642:657);
MTF_d70_r(5) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = r(646, 644:656);
MTF_d70_r(6) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));

%8 through 20
curr_region = r(439, 860:876);
MTF_d70_r(7) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = r(474, 861:875);
MTF_d70_r(8) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = r(508, 881:897);
MTF_d70_r(9) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = r(542, 880:895);
MTF_d70_r(10) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = r(576, 880:895);
MTF_d70_r(11) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = r(611, 878:894);
MTF_d70_r(12) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = r(644, 864:872);
MTF_d70_r(13) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));

%now green

%1 through 6
curr_region = g(390, 618:682);
MTF_d70_g(1) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = g(440, 632:667);
MTF_d70_g(2) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = g(492, 637:662);
MTF_d70_g(3) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = g(544, 641:658);
MTF_d70_g(4) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = g(595, 642:657);
MTF_d70_g(5) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = g(646, 644:656);
MTF_d70_g(6) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));

%8 through 20
curr_region = g(439, 860:876);
MTF_d70_g(7) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = g(474, 861:875);
MTF_d70_g(8) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = g(508, 881:897);
MTF_d70_g(9) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = g(542, 880:895);
MTF_d70_g(10) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = g(576, 880:895);
MTF_d70_g(11) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = g(611, 878:894);
MTF_d70_g(12) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = g(644, 864:872);
MTF_d70_g(13) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));

%now blue

%1 through 6
curr_region = b(390, 618:682);
MTF_d70_b(1) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = b(440, 632:667);
MTF_d70_b(2) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = b(492, 637:662);
MTF_d70_b(3) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = b(544, 641:658);
MTF_d70_b(4) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = b(595, 642:657);
MTF_d70_b(5) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = b(646, 644:656);
MTF_d70_b(6) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));

%8 through 20
curr_region = b(439, 860:876);
MTF_d70_b(7) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = b(474, 861:875);
MTF_d70_b(8) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = b(508, 881:897);
MTF_d70_b(9) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = b(542, 880:895);
MTF_d70_b(10) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = b(576, 880:895);
MTF_d70_b(11) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = b(611, 878:894);
MTF_d70_b(12) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
curr_region = b(644, 864:872);
MTF_d70_b(13) = (max(curr_region)-min(curr_region))/(max(curr_region)+min(curr_region));
