Removing labels in scikit-image

微笑、不失礼 提交于 2019-12-11 14:57:43

问题


I have labeled an binary image

imageLabels = morphology.label(imageBinary, background=255)

However when I check the number of labels, I get 535 elements.

print(len(imageLabels))

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

回答1:


I think morphology.remove_small_objects(image, min_px_size) does what you're looking for. Here's an example that uses that function:

http://scikit-image.org/docs/dev/auto_examples/applications/plot_coins_segmentation.html#edge-based-segmentation



来源:https://stackoverflow.com/questions/23584178/removing-labels-in-scikit-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!