I am doing Sobel edge detection in openCV using the with following parameters:
cv.Sobel(mat, edgemat, 1, 1)
# mat -> source image
# edgemat -> taget output image
# 1 -> xorder (int) – Order of the derivative x
# 1 -> yorder (int) – Order of the derivative y
# apertureSize (int) – Size of the extended Sobel kernel -> its by default set to 3
I also did the Sobel edge detection on the image using GIMP.
The source image is: The output by openCV is The output by GIMP is
Why such a big difference between the outputs by openCV and GIMP. The quality of output by GIMP surpasses openCV by light years.
Simple answer: You are doing it wrong. See the documentation - what you are doing is computing the d^2/(dx dy)
derivative of the image - that means "how do the horizontal edges change vertically" (or, equivalently, "how do the vertical edges change horizontally"), that means, for a vertical or horizontal edge you expect an output of zero (because it doesn't change in the direction perpendicular to it). So, what you are doing with your opencv line is not edge detection at all. You probably want something like sobel with 1, 0
as parameters and 0, 1
, then square those results and add them up, then take the square root of the result. That might result in something like what GIMP is doing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With