From: J B on
Hi everyone,

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');
From: Rune Allnor on
On 27 apr, 00:45, J B <trifinit...(a)googlemail.com> wrote:
> Hi everyone,
>
> 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?

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
From: Oliver Woodford on
J B wrote:
> Hi everyone,
>
> 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');

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.
From: ImageAnalyst on
The edge() version is the full Sobel filter image (like the imfilter
version) but has been thresholded and skeletonized. You can threshold
by doing
thresholdedImage = imfilter_image > thresholdValue;
and skeletonize by doing
edgeImage = bwmorph(thresholdedImage, 'skel');

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.