% dip08_0.m	       gr_nov16
% a simple smoothing - sharpening test on the Monroe-Einstein image
% note strong effects of noise

f = imread('./img/monroeinstein.tif');
f = double(rgb2gray(f));
f = f(1:2:end,1:2:end);
figure(1); imshow(f,[]); pause();

w = [1 1 1; 1 1 1; 1 1 1]/9;
% w = [1 2 1; 2 4 2; 1 2 1]/16; % ("restoration" is unstable anyway)
g = f;
for i = 1:80,
    g = filter2(w,g);
    figure(1); imshow([f g],[0 255]); drawnow;
    G = abs(fftshift(fft2(g)));  figure(2); imshow(log(G+1),[]); drawnow;
    if i==1, pause(), end
    end;
return;

%%
gg = g;
% gg = double(uint8(g));
 gg = gg ;% + randn(size(g))*1e-6;

w = [-1 -1 -1; -1 9 -1; -1 -1 -1]; % Unsharp masking
for i = 1:16,   % for i>14 the image is dominated by a strong high-freq component
    gg = filter2(w,gg);
    figure(1); imshow([f gg],[0 255]); pause();
%     Gn = abs(fftshift(fft2(gg)));  imshow(log(Gn+1),[]); drawnow; 
    end;
