f = imread('moon.tif');
h = fspecial('sobel');
freqz2(h);
PQ = paddedsize(size(f));
H = freqz2(h, PQ(1), PQ(2));
H1 = ifftshift(H);
gs = imfilter(double(f),h);
gf = dftfilt(f,H1);
subplot(3,2,1);
imshow (f , []);
subplot(3,2,3);
imshow (gs , []);
subplot(3,2,5);
imshow (gf , []);
subplot(3,2,2);
imshow (abs(H) , []);
subplot(3,2,4);
imshow (abs(H1) , []);
subplot(3,2,6);
imshow (abs(gf)>0.2*abs(max(gf(:))));
d = abs(gs - gf);
m1 = max(d(:));
m2 = min(d(:));
disp(['max = ',num2str(m1),'     min = ', num2str(m2)])







