induwara.lk
induwara.lkAI · Segmentation metrics

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.

By Induwara AshinsanaUpdated Jul 9, 2026
Dice coefficient calculator

Items separated by the chosen separator. Repeats and order are ignored.

Compared against A as a set.

Separator
Examples
Dice coefficient
0.6667
66.67% · range 0–1
Dice distance
0.3333
1 − DSC
2·TP / (2·TP + FP + FN)
6 / 9
TP 3 · FP 1 · FN 2
Interpretation
Moderate overlapPartial agreement; whether it is enough depends on the task.
DSC = 2·|A ∩ B| / (|A| + |B|) = 2·3 / (4 + 5) = 6 / 9 = 0.6667
distance = 1 − 0.6667 = 0.3333
Jaccard index / IoU
0.5000

J = |A ∩ B| / |A ∪ B| = DSC / (2 − DSC). Always ≤ the Dice score.

Same as F1 score
0.6667

With TP/FP/FN, Dice equals the F1 score numerically — different intent, same arithmetic.

Cross-check. The direct formula gives 0.6667; deriving it a second way from the Jaccard index, DSC = 2J / (1 + J), gives 0.6667. They reconcile, as they must. This equals 1 − SciPy's dice() dissimilarity.

Overlap breakdown

QuantityValue
|A| (TP + FP)4
|B| (TP + FN)5
|A ∩ B| = TP3
FP (in A only)1
FN (in B only)2
|A ∪ B| = TP + FP + FN6
Set A4
applebananacherrydate
Set B5
bananacherrydateelderberryfig
Intersection A ∩ B3
bananacherrydate
Union A ∪ B6
applebananacherrydateelderberryfig

Method: DSC = 2·|A ∩ B| / (|A| + |B|) = 2·TP / (2·TP + FP + FN) — Dice (1945) / Sørensen–Dice, the same coefficient MONAI and SciPy use. The both-empty case is defined as DSC = 1, not NaN. Sources cited below; nothing leaves this page.

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

Two sets — A = {apple, banana, cherry, date}, B = {banana, cherry, date, elderberry, fig}

  1. Intersection A ∩ B = {banana, cherry, date} → 3
  2. |A| = 4, |B| = 5
  3. DSC = 2·3 / (4 + 5) = 6 / 9 = 0.6667
  4. Cross-check: J = 3 / 6 = 0.5; 2·0.5 / 1.5 = 0.6667 → Moderate overlap

Segmentation counts — TP = 50, FP = 10, FN = 20

  1. Denominator = 2·TP + FP + FN = 100 + 10 + 20 = 130
  2. DSC = 2·50 / 130 = 100 / 130 = 0.7692
  3. IoU cross-check: J = 50 / (50 + 10 + 20) = 0.625
  4. 2·0.625 / 1.625 = 1.25 / 1.625 = 0.7692 → Moderate overlap

Binary masks — pred = [1,1,0,1,0,1], truth = [1,0,0,1,1,1]

  1. pos1 (1,1)=TP, pos2 (1,0)=FP, pos4 (1,1)=TP, pos5 (0,1)=FN, pos6 (1,1)=TP
  2. TP = 3, FP = 1, FN = 1
  3. DSC = 2·3 / (2·3 + 1 + 1) = 6 / 8 = 0.7500
  4. distance = 1 − 0.75 = 0.25 → Moderate overlap

Frequently asked questions

Sources & references

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

Rate this tool
Be the first to rate

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.