【问题标题】:Fill in a region of a binary image which is not completely closed填充二值图像中不完全闭合的区域
【发布时间】:2016-10-11 19:14:10
【问题描述】:

在 MatLab 中,我有一个二进制图像,我正试图填补一个洞。问题是该地区大部分(但不是完全)封闭。是否有任何现有的视觉处理功能可以做到这一点?我必须编写自己的算法吗?

原创/期望

另一个单独的问题是,我无法在二进制图像中检测细尾状结构。我需要移除这些类型的结构而不移除它所连接的较大的主体。是否有任何现有的视觉处理功能可以做到这一点?我必须编写自己的算法吗?

原创/期望

【问题讨论】:

  • 任何这样的算法也会砍掉腿。
  • 没关系。我只需要主体区域

标签: matlab image-processing matlab-cvst


【解决方案1】:

在第一个示例中,您可以使用imclose 执行膨胀,然后执行腐蚀以闭合这些边缘。然后你可以跟进imfill完整填写。

img = imread('http://i.stack.imgur.com/Pt3nl.png');
img = img(:,:,1) > 0;

% You can play with the structured element (2nd input) size
closed = imclose(img, strel('disk', 13));
filled = imfill(closed, 'holes');

同样,对于您的第二组图像,您可以使用imopen(先腐蚀后膨胀)去除尾部。

img = imread('http://i.stack.imgur.com/yj32n.png');
img = img(:,:,1);

% You can play with the structured element (2nd input) size
% Increase this number if you want to remove the legs and more of the tail
opened = imopen(img, strel('disk', 7));

更新

如果你想要上面“封闭”图像的中心开口的质心,你可以通过从filled 中减去closed 得到一个正是这个开口的蒙版。

% Find pixels that were in the filled region but not the closed region
hole = filled - closed;

% Then compute the centroid of this
[r,c] = find(hole);
centroid = [mean(r), mean(c)];

【讨论】:

  • 有效!太感谢了。我一直在努力解决这个问题 3 个小时!
  • @user3315340 如果它对您有用,请考虑将其标记为解决方案,以帮助其他有类似问题的人。
  • 另一个快速问题。是否可以找到“封闭图像”的黑色封闭圆圈的质心坐标?
  • @user3315340 更新了解决方案。
猜你喜欢
  • 1970-01-01
  • 2021-08-11
  • 1970-01-01
  • 2013-02-17
  • 1970-01-01
  • 2013-05-20
  • 1970-01-01
  • 1970-01-01
  • 2016-05-12
相关资源
最近更新 更多