title: TypeError: Label image must be of integral type
body: <p>I would like to detect some circles (circle like cells) in an image, and then measure the greenness (number of green pixel?) in each circle. </p>
  
  <p>I am using <a href="https://stackoverflow.com/questions/28281742/fitting-a-circle-to-a-binary-image">this</a> discussion with the following code:</p>
  
  <pre><code>from skimage import io, color, measure, draw, img_as_bool
  import numpy as np
  from scipy import optimize
  import matplotlib.pyplot as plt
  
  
  image = img_as_bool(color.rgb2gray(io.imread('0.06_3a.jpg')))
  regions = measure.regionprops(image)
  bubble = regions[0]
  
  y0, x0 = bubble.centroid
  r = bubble.major_axis_length / 2.
  
  def cost(params):
      x0, y0, r = params
      coords = draw.circle(y0, x0, r, shape=image.shape)
      template = np.zeros_like(image)
      template[coords] = 1
      return -np.sum(template == image)
  
  x0, y0, r = optimize.fmin(cost, (x0, y0, r))
  
  import matplotlib.pyplot as plt
  
  f, ax = plt.subplots()
  circle = plt.Circle((x0, y0), r)
  ax.imshow(image, cmap='gray', interpolation='nearest')
  ax.add_artist(circle)
  plt.show()
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>    /home/mahsa/anaconda3/lib/python3.6/site-packages/skimage/util/dtype.py:118: UserWarning: Possible sign loss when converting negative image of type float64 to positive image of type bool.
    .format(dtypeobj_in, dtypeobj_out))
  /home/mahsa/anaconda3/lib/python3.6/site-packages/skimage/util/dtype.py:122: UserWarning: Possible precision loss when converting from float64 to bool
    .format(dtypeobj_in, dtypeobj_out))
  Traceback (most recent call last):
    File "img.py", line 28, in &lt;module&gt;
      regions = measure.regionprops(image)
    File "/home/mahsa/anaconda3/lib/python3.6/site-packages/skimage/measure/_regionprops.py", line 539, in regionprops
      raise TypeError('Label image must be of integral type.')
  TypeError: Label image must be of integral type.
  </code></pre>
  
  <ol>
  <li><p>What does this error mean and what should i do to fix it?</p></li>
  <li><p>After fixing this error, how do i loop through all the pixels in each region to count the green pixels?</p></li>
  </ol>
  
  <p>Thank you very much for your help </p>