Image Processing Reference
In-Depth Information
Function edges=sobel33(image)
%derive edges by 3*3 Sobel operator
%
% Usage: [new image]=sobel33(image)
%
% Parameters: image-array of points
%
% Author: Mark S. Nixon
%get dimensions
[rows, cols]=size(image);
%set the output image to black(0)
edges (1:rows, 1:cols)= 0;
%it's like Prewitt, but the central
weights are doubled
for x=2:cols-1 %address all columns
except border
for y=2: rows-1 %address all rows
except border
%apply Mx template
x_mag=image(y-1, x-1)+2*image(y-1,x)...
+image(y+1, x-1)-image(y+1,x-1)-...
2*image(y+1, x)-image(y+1, x+1);
%apply My template
y_mag=image(y-1,x-1)+image(y,x-1)...
+image(y+1,x-1)-image(y-1, x+1)-...
2*image(y,x+1)-image(y+1,x+1);
%evaluate edge magnitude
edges(y,x,1)=sqrt((x_mag*x_mag)
+(y_mag*y_mag));
%evaluate edge direction
if x_mag==0
edges(y,x,2)=sign(y_mag)*1.5708;
else edges(y,x,2)=atan(y_mag/x_mag);
end
end
end
Magnitude of eye edges
by Prewitt
Magnitude of eye edges
by Sobel
10
10
20
20
30
30
40
40
50
50
60
60
10 20 30 40 50 60
10 20 30 40 50 60
Magnitude of Sobel edges (in comparison with Prewitt)
disp ('The direction is still much less easy to see!')
subplot(1,1,1), direction=sobel_edges(:,:,2);
imagesc(direction);
plotedit on, title ('Direction of eye edges by Sobel'), plotedit off
pause;
Title:
/a/gaia/export/ecs/isis/users/msn/mlab/chapter4/f949.eps
Creator:
MATLAB, The Mathworks, Inc.
Preview:
This EPS picture was not saved
with a preview included in it.
Comment:
This EPS picture will print to a
PostScript printer, but not to
other types of printers.
Direction of eye edges by Sobel
10
20
30
40
50
60
10
20
30
40
50
60
Direction of Sobel edges
Search WWH ::




Custom Search