I'm trying to compute the edge image of the standard cameraman image
by firstly using the imfilter function in conjunction with the Sobel
filter and then by using the integrated Matlab function edge with the
Sobel filter.
My solution to the first approach generates an image that is very
grainy and appears almost textured, although the edges are clearly
highlighted. However, the integrated function edge(image, 'sobel')
produces a clean edge image.
What could be causing the discrepancy in appearance and how do I go
about using imfilter with sobel filters to produce a clean edge image?
Thanks.
% First approach: imfilter
image = imread('cameraman.jpg');
imfilter_image = imfilter(image, fspecial('sobel'));
% Second approach: edge
edge_image = edge(image, 'sobel');
Several possible factors:
1) The output of the Sobel operator is thresholded
2) The output of the Sobel operator is screened
for connectivity, or chain lengths of connected pixels
3) The EDGE function uses a more elaborate edge detector
that is *based* on the Sobel operator
4) All of the above
5) Something else entirely
Rune
Edge detection is a two step process: 1) Filter the image, 2) Do non-maximal suppression. "edge" does both these things, while your manual filtering only does the first.
Does that answer your question?
P.S. DON"T use image as the name of your variable since this is an
important built-in function of MATLAB, which you will override by
declaring a variable with the same name. Overriding built-in
functions is a BAD practice.