What is the Dice coefficient?
The Dice coefficient, also called the Dice similarity coefficient or F1 for masks, measures how well two regions overlap. It equals two times the area of the intersection divided by the sum of the two areas, giving a value from 0 for no overlap to 1 for a perfect match. In segmentation, the two regions are the predicted mask and the ground-truth mask.
It is closely related to intersection over union but gives more weight to the overlapping region, so Dice scores are generally a bit higher than IoU for the same prediction.
Key takeaways
- Dice is twice the intersection divided by the sum of both regions.
- It ranges from 0 (no overlap) to 1 (perfect overlap).
- It is monotonically related to IoU but reports higher values.
How it works
You count the overlapping area between prediction and ground truth, double it, and divide by the total area of both. Because it is equivalent to the F1 score computed over pixels, Dice balances precision and recall of the segmented region, penalizing both missed area and spurious area.
Why it matters
Dice is the default overlap metric in medical image segmentation, where accurately delineating a structure such as a tumor or organ is the whole point and small regions must be scored fairly. Its sensitivity to overlap on small targets is a key reason it is preferred there over raw pixel accuracy.
Frequently asked questions
Is the Dice coefficient the same as F1?
Yes, when computed over pixels it is mathematically the F1 score of the segmented region, balancing precision and recall.
Why is Dice higher than IoU?
Both measure overlap, but Dice weights the intersection more heavily, so for the same prediction it produces a larger value than IoU.
Related terms