Dice coefficient

The Dice coefficient is an overlap metric for comparing two regions, defined as twice the size of their intersection divided by the sum of their sizes. In segmentation it measures how closely a predicted mask matches the ground truth, and it is especially common in medical imaging.

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 two Dice scores for the same model can disagree

Dice looks like one well-defined number, but published Dice scores often aren't comparable, even for the same model on the same data. Three choices change the result:
  • Per-image average or pooled. Averaging Dice image by image gives small objects the same weight as large ones. Pooling every pixel first lets large regions dominate. The two can differ noticeably.
  • Empty masks. When an image has none of a class and the model correctly predicts none, Dice is zero divided by zero. Some pipelines count that as a perfect 1, some skip the image, and some count it as 0.
  • Dice or IoU. Dice equals 2 × IoU / (1 + IoU), so an IoU of 0.5 is a Dice of about 0.67. Comparing one paper's Dice to another paper's IoU flatters the Dice.
Small, thin structures make all three choices matter more, because a one-pixel boundary error is a large share of a small mask. Before trusting a Dice number, look at the masks it's computed on. In Voxel51 you can view ground truth and predicted masks on the same image and filter by class to see which structures drive the score.

PhenoBench

2,179 images

Field images of sugar beet crops and weeds with semantic, plant, and leaf instance masks.

Try this: Compare the plant and leaf instance masks on the same image. Leaves are small and thin, the case where a few pixels of boundary error cost Dice the most.

Open PhenoBench in Voxel51

Free with a work or .edu email.

Go deeper

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

black and white photo of Jesse Mostipak
Director of Growth
Jesse Mostipak is the Director of Growth at Voxel51, where the work is helping humans find and trust what the brand knows, and teaching the Google knowledge graph and the LLMs answering on their behalf to do the same. That question, how knowledge gets built inside a system, is one Jesse has been chasing for years. Earlier versions of it ran through a New York City high school science classroom, data science and machine learning, and developer relations at Kaggle, Posit (formerly RStudio), and Baseten. The answer doesn't change much depending on whether the learner is a teenager, a software engineer, or a knowledge graph. Jesse holds a Master's in Education from CUNY Hunter College. LinkedIn
See all articles by Jesse Mostipak
Last updated November 3, 2026

Building visual or physical AI?

Let's talk.