如何在ndimage.find_object ...颜色功能之后?

时间:2012-06-25 22:00:07

标签: python image-processing scipy

我有一个大图像,标签后有大约500个功能。我知道如何使用find_object将它们放入切片中但我想给它们着色以便我可以看到结果。有什么快速的建议吗?

1 个答案:

答案 0 :(得分:7)

您可以像这样使用matplotlib:

import scipy
from scipy import ndimage
import matplotlib.pyplot as plt

im = scipy.misc.imread('all_blobs.png',flatten=1)
im, number_of_objects = ndimage.label(im)
blobs = ndimage.find_objects(im)

plt.imsave('blobs.png', im)
for i,j in enumerate(blobs):
    plt.imsave('blob'+str(i)+'.png',im[j])

原始图片:

enter image description here

标记图片:

enter image description here

包含斑点的切片:

enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here {{ 0}}