pairwise_pixel_stats
Compute the # of TP, FP, FN pixels for each object in a labelled/semantic mask.
Optionally a binary metric can be computed instead of the satistics.
Atleast 2x faster than computing with np.histogram2d
.
Parameters¶
true : np.ndarray
Ground truth (semantic or labelled mask). Shape (H, W).
pred : np.ndarray
Predicted (semantic or labelled mask). Shape (H, W).
num_classes : int, optional
Number of classes in the dataset. If None, stats are computed for instances.
If not None stats are computed for classes i.e. semantic segmentation masks.
metric_func : Callable, optional
A binary metric function. e.g. `iou_score` or `dice`.
Returns¶
List[np.ndarray, ...] or None:
A List of 2D arrays (i, j) where i corresponds to a ground
truth label and j corresponds to a predicted label. Each value
of the matrix is the computed statistic or metric at pos (i, j).
By default. returns the tp, fp, and fn matrices.
If stats computed for instances:
Shape: (n_labels_gt, n_labels_pred). Dtype. float64.
If stats computed for classes:
Shape: (num_classes, num_classes). Dtype. float64.