You are on page 1of 1

clc;

clear all;
close all;

disp('loading....20..30..87..%')
A=imread('C:\Users\lenovo\Desktop\csdd\cat','png');
figure(3);
imshow(A);

abw=rgb2gray(A);
[nx,ny]=size(abw);
figure(1),subplot(2,2,1),imshow(abw);
title('grayscale image');

disp('fft');
tic;
At=fft2(abw);
F=log(abs(fftshift(At))+1);
F=mat2gray(F);
figure(4)
imshow(F,[]);

disp('zeroing out small frequency components');


tic;
count_pic=2;
for thresh=0.1*[0.001 0.005 0.01]*max(max(abs(At)));
ind=abs(At)>thresh;
count=nx*ny-sum(sum(ind));
Atlow=At.*ind;
percent=100-count/(nx*ny)*100;
Alow=uint8(ifft2(Atlow));
figure(1),subplot(2,2,count_pic),imshow(Alow);
count_pic=count_pic +1;
drawnow
title([num2str(percent) '% of fft basis'],'Fontsize',18)
end

figure
Anew=imresize(abw,.1);
surf(double(Anew));

figure
Anewlow=imresize(Alow,.1);
surf(double(Anewlow));

You might also like