openCV 与 GIMP,openCV 中边缘检测失败

发布于 11-13 08:34 字数 663 浏览 4 评论 0原文

我正在 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 的输出为 openCV output GIMP 的输出是 GIMP output

为什么 openCV 和 GIMP 的输出之间有这么大的差异。 GIMP 的输出质量比 openCV 好几个光年。

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: Source image
The output by openCV is openCV output
The output by GIMP is GIMP output

Why such a big difference between the outputs by openCV and GIMP. The quality of output by GIMP surpasses openCV by light years.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

带刺的爱情2024-11-20 08:34:41

简单的回答:你做错了。请参阅文档 - 您正在做的是计算图像的 d^2/(dx dy) 导数 - 这意味着“水平边缘如何垂直变化”(或者等效地,“垂直边缘如何水平变化”),这意味着,对于一个垂直或水平边缘,您期望输出为零(因为它在垂直于它的方向上不会改变)。所以,你用 opencv 线所做的根本不是边缘检测。您可能想要像 sobel 这样的东西,以 1, 0 作为参数,以 0, 1 为参数,然后对这些结果求平方并将它们相加,然后取结果的平方根。这可能会导致类似 GIMP 正在做的事情。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文