%% Extract 2-D Pedestal Edges
% The Sobel edge-finding operation uses a 2-D convolution to detect edges in images and other 2-D data.
% 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)

%
% Convolve the rows of A with the vector u, and then convolve the rows of the result with the vector v. The convolution extracts the horizontal edges of the pedestal.

u = [1 0 -1]';
v = [1 2 1];
Ch = conv2(u,v,A);
mesh(Ch)

%
% To extract the vertical edges of the pedestal, reverse the order of convolution with u and v.

Cv = conv2(v,u,A);
mesh(Cv)

%
% Compute and plot the combined edges of the pedestal.

figure
mesh(sqrt(Ch.^2 + Cv.^2))

% Copyright 2012 The MathWorks, Inc.