python - 将边缘检测转换为蒙版

标签 python opencv computer-vision metal edge-detection

给我应用边缘检测滤镜的图像,将如何实现标记段中点的“和”的蒙版(希望高效/高效)?
图片说明:
enter image description here
先感谢您。
更新:
添加了更亮的图像(https://imgur.com/a/MN0t3pH)的示例。
如您在下图中所看到的,我们假设当用户标记一个区域(ROI)时,将有一个对象从其背景中“突出”。我们的最终目标是获得该对象的最准确的“蒙版”,因此我们可以将其用于ML处理。
enter image description here

最佳答案

1.
鉴于您拥有“ROI”监督,我强烈建议您探索GrabCut(由YoniChechnik提议):
牧师C,科尔莫哥洛夫V,布莱克A. "GrabCut" interactive foreground extraction using iterated graph cuts。图形上的ACM事务(TOG)。 2004年。
要了解其工作原理,可以使用PowerPoint的“背景消除”工具:
enter image description here
这是基于GrabCut算法的。
这是在Power Point中的外观:
enter image description here
GrabCut主要根据前景/背景颜色分布将前景对象分割为选定的ROI,而边缘/边界信息则较少,尽管可以将这些额外信息集成到公式中。
似乎opencv具有GrabCut的基本实现,请参见here

2.
如果正在寻找仅使用边界信息的方法,则可能会发现this answer有用。

3.
另一种方法是使用NCuts:
Shi J,Malik J. Normalized cuts and image segmentation。关于模式分析和机器智能的IEEE Transactions 2000。
如果您有非常可靠的边缘图,则可以将NCuts使用的“亲和矩阵”修改为二进制矩阵

         0  if there is a boundary between i and j
w_ij =   1  if there is no boundary between i and j
         0  if i and j are not neighbors of each other
NCuts可以看作是一种估计“鲁棒连接组件”的方法。

关于python - 将边缘检测转换为蒙版,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62622154/

相关文章:

c++ - 基于 OpenCV DFT 的卷积被移位

python - 如何缩小 avi 文件的数据集输出

opencv - 使用OpenCV Sobel算子计算图像梯度方向

python - opencv 和 intel galileo gen2 上的慢速人脸检测

objective-c - 图像上的人脸对齐算法

python - 合并具有不同索引的数据帧

python - 如何根据条件有效地将函数应用于数组中的值?

python - 如何实时解决线程死锁?

python - 解释一下python切片问题

python - OpenCV python 中的实时热图生成