Segmentation IoU Calculator

Estimate IoU, Dice, precision, recall, and error rates. Test overlap quality from pixel count inputs. Validate segmentation performance with clear metrics, exports, and charts.

Calculator Inputs

Enter confusion-style pixel counts for a single class. You can optionally derive TN from image dimensions and batch size.

Formula Used

IoU = (TP + ε) / (TP + FP + FN + ε)
Dice = (2TP + ε) / (2TP + FP + FN + ε)
Precision = (TP + ε) / (TP + FP + ε)
Recall = (TP + ε) / (TP + FN + ε)
Specificity = (TN + ε) / (TN + FP + ε)
Accuracy = (TP + TN + ε) / (TP + FP + FN + TN + ε)

TP is the overlapping foreground area, FP is extra predicted foreground, FN is missed foreground, and TN is correctly rejected background. Epsilon is optional smoothing for zero-denominator edge cases.

How to Use This Calculator

  1. Choose the class you want to evaluate, such as road, tumor, lane, or person.
  2. Enter TP, FP, and FN from your mask comparison process.
  3. Enter TN directly, or provide image width, image height, and batch size to derive it.
  4. Optionally add a threshold, class frequency, epsilon, and output precision.
  5. Click the calculate button to show the result above the form.
  6. Review the detailed metric table, performance chart, and pixel composition chart.
  7. Use the CSV or PDF buttons to export the visible report.

Example Data Table

Class TP FP FN IoU Dice
Road 89,200 4,200 3,800 91.77% 95.71%
Person 12,400 2,100 2,600 72.51% 84.07%
Vehicle 22,650 1,850 1,450 87.28% 93.21%

These values are sample inputs for testing the layout, formulas, and export buttons.

FAQs

1) What does IoU measure in segmentation?

IoU measures overlap between the predicted mask and the ground-truth mask. It divides their intersection by their union, so larger overlap yields a higher score.

2) Why is Dice score shown too?

Dice is another overlap metric often reported in medical and vision papers. It is closely related to IoU, but it gives slightly more weight to shared positive pixels.

3) Why is TN optional in this calculator?

Many segmentation workflows focus on foreground overlap and do not store TN directly. The page lets you derive TN from dimensions or omit TN when only overlap metrics matter.

4) What happens if the masks are empty?

If the union becomes zero, IoU is undefined unless you apply a small epsilon. The epsilon field helps stabilize such edge cases during experimentation and reporting.

5) How should I interpret IoU values?

Interpretation depends on the task, object size, and label quality. High-risk or tiny-object problems may need stronger scores, while noisy masks can make moderate IoU acceptable.

6) What is the difference between precision and recall here?

Precision tells you how much predicted foreground was correct. Recall tells you how much real foreground was successfully captured by the model.

7) Why include class frequency?

Class frequency helps estimate a weighted IoU contribution for a class. That is useful when you later combine several class scores into a frequency-aware summary.

8) Can I use this for multiclass segmentation?

Yes. Evaluate one class at a time, then combine the class-wise IoU values outside this page to produce macro IoU, mean IoU, or weighted summaries.


Related Calculators

batch size calculatorstride calculatorimage size calculatorintersection over unionimage resolution calculatorpixel density calculatorbounding box areaimage resize scaleanchor box sizefeature map size

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.