In [1]:
from numpy import *
from numpy import random
from scipy.ndimage import filters
from PIL import *
from pylab import *
from scipy.ndimage import measurements, morphology
In [2]:
im = array(Image.open('data/houses.png').convert('L'))
im = 1*(im<128)
In [3]:
labels, nbr_objects = measurements.label(im)
print "Number of objects", nbr_objects
In [4]:
figure(figsize=(6, 12))
imshow(labels)
show()
In [5]:
figure()
hist(labels.flatten())
axis([5, 45, 0, 20000])
show()