我在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边缘检测。在
源映像是: openCV的输出是 GIMP的输出是
为什么openCV和GIMP的输出之间有这么大的差别。GIMP的输出质量超过openCV光年。在
答案很简单:你做错了。请看the documentation-你所做的是计算图像的
d^2/(dx dy)
导数-这意味着“水平边缘如何垂直变化”(或者,等价地,“垂直边缘如何水平变化”),也就是说,对于垂直边或水平边,您希望输出为零(因为它不会在垂直于它的方向上更改)。所以,你用opencv线做的根本不是边缘检测。您可能需要类似sobel的东西,其中1, 0
作为参数,0, 1
,然后将这些结果平方并相加,然后取结果的平方根。这可能会导致类似GIMP所做的事情。在相关问题 更多 >
编程相关推荐