openCV vs GIMP,openCV中的边缘检测失败

2024-10-01 07:39:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我在openCV中使用以下参数进行Sobel边缘检测:

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

我还用GIMP对图像进行了Sobel边缘检测。在

源映像是:Source image openCV的输出是openCV output GIMP的输出是GIMP output

为什么openCV和GIMP的输出之间有这么大的差别。GIMP的输出质量超过openCV光年。在


Tags: oftheimagesource参数orderopencvcv
1条回答
网友
1楼 · 发布于 2024-10-01 07:39:34

答案很简单:你做错了。请看the documentation-你所做的是计算图像的d^2/(dx dy)导数-这意味着“水平边缘如何垂直变化”(或者,等价地,“垂直边缘如何水平变化”),也就是说,对于垂直边或水平边,您希望输出为零(因为它不会在垂直于它的方向上更改)。所以,你用opencv线做的根本不是边缘检测。您可能需要类似sobel的东西,其中1, 0作为参数,0, 1,然后将这些结果平方并相加,然后取结果的平方根。这可能会导致类似GIMP所做的事情。在

相关问题 更多 >