lazyslide.metrics.segmentation.dice#
- dice(stats)#
Compute Dice coefficient from segmentation statistics.
The Dice coefficient (also known as Sørensen-Dice coefficient or F1 score) measures the similarity between two sets by computing twice the size of their intersection divided by the total size of both sets.
- Parameters:
- statsSegmentationStats
Segmentation statistics containing true positives (tp), false positives (fp), and false negatives (fn).
- Returns:
- float
Dice coefficient in the range [0, 1], where 1 indicates perfect overlap. A small epsilon (1e-8) is added to the denominator to avoid division by zero.
Notes
Dice = 2 * TP / (2 * TP + FP + FN) This is mathematically equivalent to the F1 score.