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.
Sobel edge detection
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Sobel edge detection
see http://www.imagemagick.org/Usage/convolve/#sobel your problem is probably a normalization and scaling issue
Re: Sobel edge detection
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.
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.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Sobel edge detection
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
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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/