删除 scikit-image 中的标签 [英] Removing labels in scikit-image
问题描述
我已经标记了一个二值图像
I have labeled an binary image
imageLabels = morphology.label(imageBinary, background=255)
但是,当我检查标签数量时,我得到了 535 个元素.
However when I check the number of labels, I get 535 elements.
print(len(imageLabels))
作为一个解决方案,我考虑使用 measure.regionprops
来移除具有小像素区域的标签.你们会如何处理这个问题?我尝试了以下方法,但出于某种原因,新数组不再被视为正确的标签元素.
As a solution for this I thought about using measure.regionprops
in order to remove the labels with a small pixel area. How would you guys approach this? I have tried the following, but for one reason or another the new array is no longer seen as a correct label element.
i=0
for labelprop in measure.regionprops(imageLabels):
if (labelprop.area > 100):
imageLabels_keep.append(imageLabels[i])
i=i+1
推荐答案
我认为 morphology.remove_small_objects(image, min_px_size)
可以满足您的需求.下面是一个使用该函数的示例:
I think morphology.remove_small_objects(image, min_px_size)
does what you're looking for. Here's an example that uses that function:
这篇关于删除 scikit-image 中的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!