def compute_centroids(object_matrix, preserve_ids=False, round_val=False):
# if ids=true, then write a matrix equal to size of maximum
# value, else, order in object label order
# if round = true, round centroid coordinates to nearest integer
# when rounding, TODO: make sure we don't leave the volume
import skimage.measure as measure
centroids = []
# Threshold data
rp = measure.regionprops(object_matrix)
for r in rp:
if round_val > 0:
centroids.append(np.round(r.Centroid, round_val))
else:
centroids.append(r.Centroid)
return centroids
评论列表
文章目录