仅在图像的特定部分中检测边缘 [英] Detecting edge only in particular portion of an image

查看:110
本文介绍了仅在图像的特定部分中检测边缘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

推荐答案

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

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.

我建议的算法

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.

好的,不同的方法:

在matlab中使用 hough 例程。 houghlines hough houghpeaks 是相关功能。如果只有一条线与您感兴趣的区域相交,那么您就完成了。该行是您想要的结果。

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.

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

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.

这篇关于仅在图像的特定部分中检测边缘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆