如何检测掩模图像中不存在的对象并将其从原始图像中移除?
How to detect an absent object in the mask image and remove it in the original image?
下面是两张图片:图片1是原始图片的二值化图片,图片2是'masked'图片。图 2 是我为分割目的提取的斑点的中心部分(核)。
图片 1:
图 2:
我的问题是,图像 2 中的一个 blob 被删除了(如删除的 blob 上的灰色箭头所指),我怎样才能 让 原始图像知道不存在的对象因此完全删除图像 1 中的整个斑点(提到的斑点用灰色箭头指向)?这就像“这里没有核,所以不需要你”的移除。图片 2 是图片 1 的某种 'seed' 图片。
两幅图像中的斑点大小不同,因为图像 1 中的斑点是细胞,而图像 2 中的斑点实际上是这些细胞的细胞核。
我在两张图片上都使用 bwconncomp
,两张图片中的 NumObjects
不同(当然不同)。我该如何使用这些信息?
请帮帮我。非常感谢!!
(我使用的是 MATLAB R2013a)
幸运的是,由于逻辑索引,这很简单。
%# label image 1
lblOne = bwlabel(image1);
%# identify labels overlapping with the seed
%# ">0" not needed if image2 is of class logical
labelsInSeed = lblOne(image2>0);
%# remove all labels not overlappign with the seed from image 1
%# ensure we're not accidentially pick up label 0 (the background)
image1cleanedUp = ismember(lblOne, labelsInSeed(labelsInSeed>0));
请注意,此方法可能会在图像 1 上隐式执行 "bwareaopen",因为它可能不会拾取单元格外围的孤立像素。如果您不希望这种情况发生,请事先使用 imclose
。
下面是两张图片:图片1是原始图片的二值化图片,图片2是'masked'图片。图 2 是我为分割目的提取的斑点的中心部分(核)。
图片 1:
图 2:
我的问题是,图像 2 中的一个 blob 被删除了(如删除的 blob 上的灰色箭头所指),我怎样才能 让 原始图像知道不存在的对象因此完全删除图像 1 中的整个斑点(提到的斑点用灰色箭头指向)?这就像“这里没有核,所以不需要你”的移除。图片 2 是图片 1 的某种 'seed' 图片。
两幅图像中的斑点大小不同,因为图像 1 中的斑点是细胞,而图像 2 中的斑点实际上是这些细胞的细胞核。
我在两张图片上都使用 bwconncomp
,两张图片中的 NumObjects
不同(当然不同)。我该如何使用这些信息?
请帮帮我。非常感谢!!
(我使用的是 MATLAB R2013a)
幸运的是,由于逻辑索引,这很简单。
%# label image 1
lblOne = bwlabel(image1);
%# identify labels overlapping with the seed
%# ">0" not needed if image2 is of class logical
labelsInSeed = lblOne(image2>0);
%# remove all labels not overlappign with the seed from image 1
%# ensure we're not accidentially pick up label 0 (the background)
image1cleanedUp = ismember(lblOne, labelsInSeed(labelsInSeed>0));
请注意,此方法可能会在图像 1 上隐式执行 "bwareaopen",因为它可能不会拾取单元格外围的孤立像素。如果您不希望这种情况发生,请事先使用 imclose
。