get_edge_masks#

omnipose.utils.get_edge_masks(labels, dists)[source]#

Finds and returns masks that are largely cut off by the edge of the image.

This function loops over all masks touching the image boundary and compares the maximum value of the distance field along the boundary to the top quartile of distance within the mask. Regions whose edges just skim the image edge will not be classified as an "edge mask" by this criteria, whereas masks cut off in their center (where distance is high) will be returned as part of this output.

Parameters
  • labels (ND array, int) -- label matrix

  • dists (ND array, float) -- distance field (calculated with reflection padding of labels)

Returns

clean_labels -- label matrix of all cells qualifying as 'edge masks'

Return type

ND array, int