Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how after ndimage.find_object ... color features?

I have a large image which after labeling has about 500 features. I know how to get them in the slices using find_object but I want to color them so I can see the result. Any quick suggestion for that?

like image 671
Kiarash Avatar asked Jun 25 '12 22:06

Kiarash


1 Answers

You could use matplotlib like this:

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])

original image:

enter image description here

labelled image:

enter image description here

slices containing the blobs:

enter image description hereenter image description hereenter image description hereenter image description hereenter image description hereenter image description hereenter image description hereenter image description hereenter image description hereenter image description here

like image 87
fraxel Avatar answered Sep 28 '22 03:09

fraxel