title: Skimage: group labels with distance condition on outline
body: <p>I have used <em>skimage.measure.label</em> to get labels of my image but i was wondering if there was a function or a best way to group the labels with a distance condition on their outline.</p>
  
  <p>Currently i use <em>skimage.measure.regionprops</em> to analyse each label then <em>skimage.segmentation.find_boundaries</em> to get the outline of each label then i get the coordinates, i check the distance between each points, i update the label if the distance match the condition and then i reuse <em>regionprops</em> to get right labels after grouping (i will post my code soon).</p>
  
  <p>Currently work with this code:</p>
  
  <pre><code>import math
  import matplotlib.pyplot as plt
  import numpy as np
  
  from skimage.draw import ellipse
  from skimage.measure import label, regionprops
  from skimage.transform import rotate
  
  
  image = np.zeros((600, 600))
  
  rr, cc = ellipse(300, 350, 100, 220)
  rr2, cc2 = ellipse(100, 100, 20, 50)
  image[rr, cc] = 1
  image[rr2, cc2] = 1
  
  image = rotate(image, angle=15, order=0)
  
  label_img = label(image)
  regions = regionprops(label_img)
  
  fig, ax = plt.subplots()
  ax.imshow(image, cmap=plt.cm.gray)
  
  for props in regions:
      y0, x0 = props.centroid
      orientation = props.orientation
      x1 = x0 + math.cos(orientation) * 0.5 * props.major_axis_length
      y1 = y0 - math.sin(orientation) * 0.5 * props.major_axis_length
      x2 = x0 - math.sin(orientation) * 0.5 * props.minor_axis_length
      y2 = y0 - math.cos(orientation) * 0.5 * props.minor_axis_length
  
      ax.plot((x0, x1), (y0, y1), '-r', linewidth=2.5)
      ax.plot((x0, x2), (y0, y2), '-r', linewidth=2.5)
      ax.plot(x0, y0, '.g', markersize=15)
  
      minr, minc, maxr, maxc = props.bbox
      bx = (minc, maxc, maxc, minc, minc)
      by = (minr, minr, maxr, maxr, minr)
      ax.plot(bx, by, '-b', linewidth=2.5)
  
  ax.axis((0, 600, 600, 0))
  plt.show()
  </code></pre>