I am trying to label this image into two regions:
And here is my code:
from scipy.ndimage import measurements,morphology
from PIL import Image
from numpy import *
im = array(Image.open('two_leds.png').convert('L'))
im = 1*(im<200)
result = Image.fromarray((im * 255).astype(uint8))
result.save('results.png')
labels, nbr_objects = measurements.label(im)
print 'number of objects equals: {}'.format(nbr_objects)
Here is the filtered image "results.png" with low-pass filter
My problem is the output that I am getting is 1 while I am expecting 2
>>> number of objects equals: 1
Is there something wrong with the labeling code itself. It seems to me pretty straightforward