Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Sobel filter using imfilter produces grainy "edge image"

258 views
Skip to first unread message

J B

unread,
Apr 26, 2010, 6:45:42 PM4/26/10
to
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');

Rune Allnor

unread,
Apr 26, 2010, 6:55:30 PM4/26/10
to
On 27 apr, 00:45, J B <trifinit...@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

Oliver Woodford

unread,
Apr 27, 2010, 4:54:04 AM4/27/10
to

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.

ImageAnalyst

unread,
Apr 27, 2010, 6:46:36 AM4/27/10
to
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.

0 new messages