OpenCV vs GIMP, edge detection in openCV

I am doing Sobel edge detection in openCV using the 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 used Sobel edge detection in the image using GIMP.

Original Image: Source image The output of openCV is openCV output GIMP output is Gimp output

Why is there such a big difference between openCV and GIMP outputs. The quality of light years produced by GIMP is superior to openCV.

+6
source share
1 answer

The simple answer is: you are doing it wrong. See the documentation - what you do is calculate the derivative d^2/(dx dy) image - this means "how the horizontal edges change vertically" (or, equivalently, "how the vertical edges change horizontally"), that is, for vertical or horizontal edge you expect the exit of zero (because it does not change in the direction perpendicular to it). So what you do 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 collect these results and add them, then take the square root from the result. This can lead to what GIMP does.

+9
source

Source: https://habr.com/ru/post/889687/


All Articles