Dice Coefficient (Sørensen–Dice) Calculator
Compute the Dice similarity coefficient from two sets, two binary segmentation masks, or raw TP/FP/FN counts. See every arithmetic step, the Dice distance, and the related Jaccard/IoU value — all in your browser. No signup, nothing uploaded.
How it works
The Dice Similarity Coefficient(DSC), also called the Sørensen–Dice index or simply the “Dice score”, measures how much two things overlap. It was defined independently by Lee Dice in 1945 and Thorvald Sørensen in 1948, and it is the metric image-segmentation and NLP papers most often report. Two identical inputs score 1; two with nothing in common score 0.
For two sets A and B, the coefficient is twice the intersection over the sum of the two sizes:
DSC = 2·|A ∩ B| / (|A| + |B|)
In the binary-mask or classification framing used by libraries such as MONAI and SciPy, the same quantity is written with confusion counts, where TP is the positions where both masks are 1, FP is predicted-1 truth-0, and FN is predicted-0 truth-1:
DSC = 2·TP / (2·TP + FP + FN)
These are identical, because for masks |A ∩ B| = TP, |A| = TP + FP and |B| = TP + FN, so the two denominators are the same sum. The four input modes above only differ in how they reach the triple (intersection, |A|, |B|): Two sets dedupes each list and counts shared members; Binary masks tallies TP/FP/FN position by position; the two count modes take the numbers directly. Everything then funnels into the one formula.
Dice is closely tied to the Jaccard index (Intersection over Union). Since J = |A ∩ B| / |A ∪ B| = TP / (TP + FP + FN), the two convert exactly by DSC = 2J / (1 + J) and J = DSC / (2 − DSC). The calculator computes the score directly and then re-derives it from the Jaccard value as an independent check, so both routes must agree. With the TP/FP/FN framing the Dice coefficient is also numerically the F1 score— same arithmetic, different reporting intent. When both inputs are empty, |A| + |B| = 0 and the formula would divide by zero; the tool defines DSC = 1 in that case, matching SciPy's dice() dissimilarity of 0, and flags that the convention was applied.
Worked examples
Frequently asked questions
Sources & references
- Dice, L. R. (1945) — Measures of the Amount of Ecologic Association Between Species, Ecology 26(3):297–302 (original definition)
- MONAI — DiceMetric: the 2·TP / (2·TP + FP + FN) mask formulation used in medical image segmentation
- SciPy — scipy.spatial.distance.dice: the Dice dissimilarity (1 − DSC) we validate against, and the empty-input convention
The formulas on this page were last cross-checked against these sources on 2026-07-09. The Dice coefficient is a stable mathematical definition, so this tool needs no rate or schedule updates — only the worked examples are periodically re-reconciled.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a bug, edge case, or want to suggest an improvement?
Email me at [email protected] — most fixes ship within 24 hours.