%Tom J.
%Part 1 - bascially what you showed me in your office.
abc = imread('hw1.jpg');
f = im2double(abc);
f = f(:,:,3);
FT = fft2(f);
FT2 = FT;
thresh = 1;
diff_measure = .3;


FT = FT.*(abs(FT)>thresh);
result = ifft2(FT);
imshow(result);

q = f - result;
max(q(:));

while max(q(:)) < diff_measure
    %The greater the "difference" the higher the threshold - blurry the
    %image
    %I find the difference being .3 produces good result.

    thresh = thresh + 1;
    FT = fft2(f);
    FT = FT.*(abs(FT)>thresh);
    result = ifft2(FT);
    imshow(result);

    q = f - result;
    
end 

thresh

%Part 2
%GT2 = 2 *log( 1 + double(FT2));
%GT2 = GT2.*(abs(GT2)>thresh);
%result2 = ifft2(GT2);
%imshow(result2);






