Image Processing Reference
In-Depth Information
function vertical_edges=edge_x (image)
%Find edges by horizontal differencing
%
%Usage: [new image]=edge_x (image)
%
%Parameters: image-array of points
%
%Author: Mark S. Nixon
%get dimensions
[rows, cols]=size (image);
%set the output image to black
vertical_edges=zeros (rows, cols);
%this is equivalent to
vertical_edges (1:rows, 1:cols)=0
%then form the difference between horizontal
successive points
for x=1: cols-1 %address all columns except border
for y=1: rows %address all rows
vertical_edges (y,x)=
abs (image (y, x)-image (y, x+1));
Vertical edges of an eye
10
20
30
40
50
60
10
20
30
40
50
60
end
end
Vertical edge detection
disp (' ')
disp ('We detect horizontal edges by differencing vertically adjacent
points')
disp ('Notice how the side of the face now disappears, wheras the')
disp ('eyebrows appear')
%so we'll call the edge_y operator
subplot(1,2,2), horizontal=edge_y(eye);
subplot(1,2,1), imagesc(horizontal);
plotedit on, title ('Horizontal edges of an eye'), plotedit off
subplot(1,2,2), imagesc(vertical);
plotedit on, title ('Vertical edges of an eye'), plotedit off
pause;
function horizontal_edges=edge_y(image)
%Find edges by vertical differencing
%
%Usage: [new image]=edge(image)
%
%Parameters: image-array of points
%
%Author: Mark S. Nixon
%get dimensions
[rows, cols]=size (image);
%set the output image to black
horizontal_edges=zeros(rows,cols);
%then form the difference between vertical
successive points
for x=1:cols %address all columns
for y=1:rows-1 %address all rows except border
horizontal_edges (y,x)=
abs(image(y, x)-image(y+1,x));
Horizontal edges of an eye
Vertical edges of an eye
10
20
30
40
50
60
10
20
30
40
50
60
end
end
10 20 30 40 50 60
10 20 30 40 50 60
Horizontal edge detection (in comparison with vertical)
Search WWH ::




Custom Search