def edit_distance(aseg, gt, size_threshold=1000, sp=None): """Find the number of splits and merges needed to convert `aseg` to `gt`. Parameters ---------- aseg : np.ndarray, int type, arbitrary shape The candidate automatic segmentation being evaluated. gt : np.ndarray, int type, same shape as `aseg` The ground truth segmentation. size_threshold : int or float, optional Ignore splits or merges smaller than this number of voxels. sp : np.ndarray, int type, same shape as `aseg`, optional A superpixel map. If provided, compute the edit distance to the best possible agglomeration of `sp` to `gt`, rather than to `gt` itself. Returns ------- (false_merges, false_splits) : float The number of splits and merges needed to convert aseg to gt. """ if sp is None: return raw_edit_distance(aseg, gt, size_threshold) else: import agglo bps = agglo.best_possible_segmentation(sp, gt) return raw_edit_distance(aseg, bps, size_threshold)
def edit_distance(aseg, gt, size_threshold=1000, sp=None): """Find the number of splits and merges needed to convert `aseg` to `gt`. Parameters ---------- aseg : np.ndarray, int type, arbitrary shape The candidate automatic segmentation being evaluated. gt : np.ndarray, int type, same shape as `aseg` The ground truth segmentation. size_threshold : int or float, optional Ignore splits or merges smaller than this number of voxels. sp : np.ndarray, int type, same shape as `aseg`, optional A superpixel map. If provided, compute the edit distance to the best possible agglomeration of `sp` to `gt`, rather than to `gt` itself. Returns ------- (false_merges, false_splits) : float The number of splits and merges needed to convert aseg to gt. """ if sp is None: return raw_edit_distance(aseg, gt, size_threshold) else: import agglo bps = agglo.best_possible_segmentation(sp, gt) return raw_edit_distance(aseg, bps, size_threshold)
def edit_distance(aseg, gt, ws=None): if ws is None: return edit_distance_to_bps(aseg, gt) import agglo return edit_distance_to_bps(aseg, agglo.best_possible_segmentation(ws, gt))
def edit_distance(aseg, gt, ws=None): if ws is None: return edit_distance_to_bps(aseg, gt) import agglo return edit_distance_to_bps(aseg, agglo.best_possible_segmentation(ws, gt))