仅检测图像的特定部分的边缘
我只想检测红色标记区域中的边缘,如下图所示:
I want to detect the edge only in the red marked region as shown in the image below:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我只想检测红色标记区域中的边缘,如下图所示:
I want to detect the edge only in the red marked region as shown in the image below:
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
一些建议。我假设红色区域是通过鼠标输入的,并且您现在拥有要包含在边缘搜索中的区域的掩码。
我提出的算法
当然,您不需要在完整图像上运行边缘检测,但如果您不确定处理搜索区域的边界(这样您就不会在那里获得边缘)。简单地镜像该区域可能会起作用。
更新
好的,不同的方法:
使用 matlab 中的
hough
例程。houghlines
、hough
、houghpeaks
是相关函数。如果只有一条线与您感兴趣的区域相交,那么您就完成了。这条线就是你想要的结果。如果有多条线与感兴趣区域相交,则需要做更多操作。我建议计算 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
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.