def pairdist(ann1, ann2, which):
"""
Compute the pairwise euclidean distance between
the contour boundary points, and return the
minimum, maximum, or average value.
which: str
One of 'min', 'max', or 'avg'.
"""
dists = cdist(ann1.contours_to_matrix(0),
ann2.contours_to_matrix(0))
if which == 'min':
return dists.min()
elif which == 'max':
return dists.max()
elif which == 'avg':
return dists.mean()
else:
raise ValueError('invalid `which` value.')
评论列表
文章目录