霍夫变换后如何显示清晰的结果?

发布于 2025-01-01 18:38:13 字数 776 浏览 0 评论 0原文

我在 Canny 边缘检测后获取了以下图像: Canny 边缘检测结果

对它应用霍夫变换后,我得到这个结果:

在此处输入图像描述

这是非常好的结果,但我只需要每个包中的一行,这样我就可以显示第一张图片中的对象类似于三角形。我的第一个决定是计算每个捆绑包的某种“平均”线。每条线都由角度和半径定义。我找到每个束的“平均”线的方法是使用以下公式计算角度的平均值:

avgTheta = arctan(sum of sines of all thetas/sum of cosines of all theta)

我以最简单的方式计算平均半径:

avgRadius = sum of all raduises / number of raduises

但是,我得到的线并不位于束的中心。

有人可以建议更好的解决方案吗?

我正在使用霍夫变换的实现: 霍夫变换

有总是可以选择随机抽取每个捆绑包中的一行,但我不喜欢它。

如果我的问题不清楚,请告诉我,以便更好地解释问题。

提前致谢。

I have the following image acquired after a Canny edge detection:
Canny edge detection result

After Hough transformation is applied to it and I get this result:

enter image description here

This is very good result but I need just one line from each bundle so I can display that the object from the first picture resembles a triangle. My first decision was to calculate some sort of "average" line for each bundle. Each line is defined by an angle and a raduis. My way of finding the "average" line for each bundle is to calculate the average of the angles using this formula:

avgTheta = arctan(sum of sines of all thetas/sum of cosines of all theta)

I calculate the average raduis in the simplest way:

avgRadius = sum of all raduises / number of raduises

However the lines I get are not in the center of their bundles.

Can someone please advise for a better solution?

I am using this implementation of the Hough Transformation: Hough Transform

There is always the option to take one line of each bundle randomly, but I don't like it.

If my question is not clear please tell me in order to try to explain the problem better.

Thanks in advance.

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

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

发布评论

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

评论(1

抚笙 2025-01-08 18:38:13

您可以尝试以下操作:

取平均角度,而不使用任何余弦、正弦或反正切函数。只要确保你处理好包装纸即可。根据您链接的实现,在我看来,您以 pi (180 度)换行。在您的图像中,“岛(?)”右侧的几乎垂直的线束将是包装两侧线条的一个很好的例子。

此外,如果您根据 Canny 边缘检测图片中包含的点数量对线进行加权,然后在平均计算中使用该权重,您可能会获得最佳结果。也许这已经通过具有相同属性的多行来完成,我无法从您的图像或链接的代码中看出。

You could try this:

Take the average angle without any cosine, sine or arctan function. Just make sure that you handle the wrap. Based on the implementation you linked to it seems to me that you wrap at pi (180 degrees). In your image the bundle of almost vertical lines on the right side of the "island(?)" will be a good example of lines that are on both sides of the wrap.

Also you probably get the best result if you have weighted lines based on how many points they include from the Canny edge detection picture, and then use this weight in the average calculations. Maybe this is already done by having multiple lines with the same properties, I could not tell from your image or the linked code.

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