code: def distance_to_edge(labels):
      '''Compute the distance of a pixel to the edge of its object
      
      labels - a labels matrix
      
      returns a matrix of distances
      '''
      colors = color_labels(labels)
      max_color = np.max(colors)
      result = np.zeros(labels.shape)
      if max_color == 0:
          return result
      
      for i in range(1, max_color+1):
          mask = (colors==i)
          result[mask] = scind.distance_transform_edt(mask)[mask]
      return resulf distance_to_edge(labels):
      '''Compute the distance of a pixel to the edge of its object
      
      labels - a labels matrix
      
      returns a matrix of distances
      '''
      colors = color_labels(labels)
      max_color = np.max(colors)
      result = np.zeros(labels.shape)
      if max_color == 0:
          return result
      
      for i in range(1, max_color+1):
          mask = (colors==i)
          result[mask] = scind.distance_transform_edt(mask)[mask]
      return result
docs: Compute the distance of a pixel to the edge of its object
      
      labels - a labels matrix
      
      returns a matrix of distances