 % write learnlowpass('saturn.tif',150)
     
function recon = learnlowpass(image,coef) 
    warning off;
    image=imread(image);
    image=double(image);
    tmp=15*randn(size(image));
    image=image+round(tmp);
    image=uint8(image);
    k=coef;
    [m,n] = size(image);
    if mod(m,2)
        m=m-1;
    end
    if mod(n,2) 
        n=n-1;
    end
    image=image(1:m,1:n);   % original image
    IMAGE = fftshift(fft2(image));  % transformed image
    recon = zeros(m,n);     % compressed image         
     
    figure(1), clf;
    lowpass=zeros(m,n);
    lowpass((m-k)/2:(m-k)/2+k,(n-k)/2:(n-k)/2+k)=IMAGE((m-k)/2:(m-k)/2+k,(n-k)/2:(n-k)/2+k);
        
    recon=real(ifft2(fftshift(lowpass)));
	
    subplot(2,2,2),imagesc(image),colormap gray, axis image, axis off ;
    subplot(2,2,1),fftshow(image);
    subplot(2,2,3),imagesc(log(abs(lowpass))),colormap(gray),axis image,axis off;
    subplot(2,2,4),imagesc(recon),colormap(gray),axis image,axis off;
    hold on;
     
    
function IMAGE=fftshow(image)

IMAGE = fft2(image);
imagesc(fftshift(log(abs(IMAGE)))),colormap gray, axis image
    axis off;