仅检测图像的特定部分的边缘

发布于 2024-12-08 20:03:15 字数 98 浏览 1 评论 0原文

我只想检测红色标记区域中的边缘,如下图所示:

在此处输入图像描述

I want to detect the edge only in the red marked region as shown in the image below:

enter image description here

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

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

发布评论

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

评论(1

仅此而已 2024-12-15 20:03:15

一些建议。我假设红色区域是通过鼠标输入的,并且您现在拥有要包含在边缘搜索中的区域的掩码。

我提出的算法

1. Do Edge detection
2. Write your own Hough routine but only count edges if they should be included according to the mask. 
3. Pick the edge with the best score in the Hough space. 

当然,您不需要在完整图像上运行边缘检测,但如果您不确定处理搜索区域的边界(这样您就不会在那里获得边缘)。简单地镜像该区域可能会起作用。


更新

好的,不同的方法:

使用 matlab 中的 hough 例程。 houghlineshoughhoughpeaks 是相关函数。如果只有一条线与您感兴趣的区域相交,那么您就完成了。这条线就是你想要的结果。

如果有多条线与感兴趣区域相交,则需要做更多操作。我建议计算 ROI 内沿线的像素数。因此,如果该线与 ROI 相交 10 个像素,则该线的得分为 10。对所有线执行此操作,然后选择得分最高的线。

请注意,这些方法都没有针对速度进行优化。然而,它们很容易理解。

A few suggestions. I assume that the red region is input by mouse and that you now have a mask of the region that you want to include in the edge search.

My proposed algorithm

1. Do Edge detection
2. Write your own Hough routine but only count edges if they should be included according to the mask. 
3. Pick the edge with the best score in the Hough space. 

Of course you don't need to run the edge detection on the complete image but if you don't make sure that you handle the border of your search area (so you don't get edges there). Simply mirroring the area might work.


Update

Okay, different approach:

Use the hough routines in matlab. houghlines, hough, houghpeaks are the relevant functions. If only one line intersects your region of interest, you are done. The line is the result you want.

If more than one line intersect the region of interest, you need to do a bit more. I'd suggest counting the number of pixels along the line that are within the ROI. So, if the line intersects the ROI for 10 pixels, that line's score is 10. Do this for all lines and then pick the line with the highest score.

Note that none of the approaches are optimized for speed. However, they are easy to understand.

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