code: def calculate_extents(labels, indexes):
      
      fix = fixup_scipy_ndimage_result
      areas = fix(scind.sum(np.ones(labels.shape),labels,np.array(indexes, dtype=np.int32)))
      y,x = np.mgrid[0:labels.shape[0],0:labels.shape[1]]
      xmin = fix(scind.minimum(x, labels, indexes))
      xmax = fix(scind.maximum(x, labels, indexes))
      ymin = fix(scind.minimum(y, labels, indexes))
      ymax = fix(scind.maximum(y, labels, indexes))
      bbareas = (xmax-xmin+1)*(ymax-ymin+1)
      return areas / bbareas
docs: Return the area of each object divided by the area of its bounding box