Page 1 of 1

Sobel edge detection

Posted: 2013-06-03T03:43:27-07:00
by gowribala
Hi everyone,

I'm new to image processing.

I'm trying to find the edge in the images using sobel algorithm.

I'm facing one problem. i can able to detect the edge for the square image only. If the width and height of the image varies, the output is poor.

I have written the sobel algorithm in c to detect the edge. I have tested my coding with various square image of different size.

Please guide to solve this issue.

Re: Sobel edge detection

Posted: 2013-06-03T09:47:00-07:00
by fmw42
see http://www.imagemagick.org/Usage/convolve/#sobel your problem is probably a normalization and scaling issue

Re: Sobel edge detection

Posted: 2013-06-04T06:52:14-07:00
by gowribala
Thank you for your reply.

I have changed the kernel value (kernel value taken from the link provided in the previous reply) in my coding, it works better.

Please guide me how to set the kernel value.

Re: Sobel edge detection

Posted: 2013-06-04T17:45:50-07:00
by anthony
Basically the kernel values is set (scaled) so that the results produce the best contrast, without overflowing (becomming clipped) in the output image.

typically that means ensuring the sum of all the positive kernel values is equal to 1.0.

This is called normalization
http://www.imagemagick.org/Usage/convolve/#normalize

However a edge detector is a zero summing kernel. meaning that it has both positive and negative values all adding up to 0.0. But images output can typically not save negative values. As such what people do is add a 50% 'bias' to the output image so that the maximum possible range of output values fits into a 0.0 to 1.0 range

To do that the kernel is scaled so positive values add to 0.5 (50%) and a 50% bias is added to the resulting image

See Output result Bias Control
http://www.imagemagick.org/Usage/convolve/#bias

The previous link given to using the Sobel Kernel also show both usage methods
http://www.imagemagick.org/Usage/convolve/#sobel