% Preprocessing the photos taken in the lecture 15.2.2017.
%
% Samuli Siltanen Feb 2017

% Read in the low-noise image
im = imread('data/edge_blur3.tif','tif');
im = double(im);

% Read in the high-noise image
im2 = imread('data/edge_blur3_noisy.tif','tif');
im2 = double(im2);

% Extract the interesting part
mn_raw  = im(round(end/2),1108+[-128:127]);
mn2_raw = im2(round(end/2),1583+[-128:127]);
m0_raw  = mean(im(:,1108+[-128:127]));

% Normalize our data. First "left part to zero"
mn_raw0  = mn_raw-mean(mn_raw(1:64));
mn2_raw0 = mn2_raw-mean(mn2_raw(1:64));
m0_raw0 = m0_raw-mean(m0_raw(1:64));

% Normalize our data. First "left part to zero"
mn  = mn_raw0/mean(mn_raw0((end-64):end));
mn2 = mn2_raw0/mean(mn2_raw0((end-64):end));
m0 = m0_raw0/mean(m0_raw0((end-64):end));

% Save the results to file
save data/deco03 im im2 m0_raw mn_raw mn2_raw m0_raw0 mn_raw0 mn2_raw0 mn mn2 m0

