title: Extracting connected objects from an image in Python
body: <p>I have a graysacle png image and I want to extract all the connected components from my image.
  Some of the components have same intensity but I want to assign a unique label to every object.
  here is my image</p>
  
  <p><img src="https://i.stack.imgur.com/x0hhC.png" alt="enter image description here"></p>
  
  <p>I tried this code:</p>
  
  <pre><code>img = imread(images + 'soccer_cif' + str(i).zfill(6) + '_GT_index.png')
  labeled, nr_objects = label(img)
  print "Number of objects is %d " % nr_objects
  </code></pre>
  
  <p>But I get just three objects using this.
  Please tell me how to get each object.</p>