% Notes, example 2.7 clear all, close all A = im2double(imread('test_pattern.tif')); imshow(A) %filter impulse response h = [0 .125 0; .125 .5 .125; 0 .125 0]; [H,f1,f2] = freqz2(h); [F1,F2]=meshgrid(256*f1,256*f2); %perspective mesh plot figure,mesh(F1,F2,H); xlabel('Horizontal frequency (c/ph)'), ylabel('Vertical frequency (c/ph)') zlabel('Magnitude') colormap([0 0 0]); % use black only set(gca,'ydir','reverse'); %make v axis point downward %contour plot v=0:.1:1.; % contours will be from 0 to 1 in steps of 0.1 figure, [C,hc]=contour(F1,F2,H,v); % generate the contour plot, including values to label contours axis square; %make the plot square colormap([0 0 0]); % use black only xlabel('Horizontal frequency (c/ph)'), ylabel('Vertical frequency (c/ph)') clabel(C,hc) %label the contours title('Contour plot of frequency response of the filter of Example 2.7') set(gca,'ydir','reverse'); %make v axis point downward B = conv2(A,h,'same'); figure,imshow(B)