code: def calculate_perimeters(labels, indexes):
      
      #
      # Create arrays that tell whether a pixel is like its neighbors.
      # index = 0 is the pixel -1,-1 from the pixel of interest, 1 is -1,0, etc.
      #
      m = table_idx_from_labels(labels)
      pixel_score = __perimeter_scoring[m]
      return fixup_scipy_ndimage_result(scind.sum(pixel_score, labels, np.array(indexes,dtype=np.int32)))
docs: Count the distances between adjacent pixels in the perimeters of the labels