%% 2-D Pedestal
% You can digitally filter images and other 2-D data using the filter2 function, which is closely related to the conv2 function.
% Create and plot a 2-D pedestal with interior height equal to one.

A = zeros(10);
A(3:7,3:7) = ones(5);
mesh(A)

%
% Filter the data in A according to a filter coefficient matrix H, and return the full matrix of filtered data.

H = [1 2 1; 0 0 0; -1 -2 -1];
Y = filter2(H,A,'full');
mesh(Y)

%
% Rotate H 180 degrees and convolve the result with A. The output is equivalent to filtering the data in A with the coefficients in H.

C = conv2(A,rot90(H,2));
mesh(C)

% Copyright 2012 The MathWorks, Inc.