Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear;
- close all;
- P = peaks(20);
- X = repmat(P,[5 10]);
- subplot(3,1,1); imshow(X);
- title('Default image');
- F=fft2(X);
- S=abs(F);
- subplot(3,1,2); imshow(S, []);
- title('Fourier spectrum');
- Fc=fftshift(F);
- subplot(3,1,3);imshow(abs(Fc), [])
- title('Fourier spectrum shifted to center');
- figure()
- w=fspecial('sobel');
- freqz2(w', [200 100]);
- title('Sobel filter');
- H = freqz2(w', [200 100]);
- figure()
- L = imfilter(X, w);
- subplot(3,1,1); imshow(L);
- title('Spatial filtering');
- G1 = F*H;
- g1 = real(ifft2(G1));
- gc1 = g1(1 : 20, 1 : 20);
- gs1 = imfilter(X, gc1);
- subplot(3,2,3); imshow(gs1);
- title('Frequency filtering');
- subplot(3,2,4); imshow (abs(gs1) >0.2*abs(max(gs1(:))), [ ]);
- title('Frequency filtering adjusted');
- G2 = Fc*H;
- g2 = real(ifft2(G2));
- gc2 = g2(1 : 10, 1 : 10);
- gs2 = imfilter(X, gc2);
- subplot(3,2,5); imshow(gs2);
- title('Frequency filtering centred');
- subplot(3,2,6); imshow (abs(gs2) >0.2*abs(max(gs2(:))), [ ]);
- title('Frequency filtering centred adjusted');
- dif1 = norm(X-L)
- dif2 = norm(X-gs1)
- dif3 = norm(X-gs2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement