induwara.lk
induwara.lkAI · Computer vision

IoU Calculator — Intersection over Union

Compute Intersection over Union for two bounding boxes or two label sets. Get IoU, the Dice/F1 coefficient, the raw intersection and union, a threshold pass/fail verdict, and a scaled overlap diagram — instantly, in your browser, with sources cited.

By Induwara AshinsanaUpdated Jun 10, 2026
IoU Calculatorbounding boxes & label sets
Format

Four numbers: x1, y1, x2, y2 (top-left and bottom-right corners).

Four numbers: x1, y1, x2, y2 (top-left and bottom-right corners).

Examples

A detection counts as a match when IoU ≥ threshold.

Intersection over Union
0.3245
32.45%
No match (IoU < 0.5)
Dice / F1
0.4900
Verified: 2·IoU/(1+IoU)
Intersection area
4,900
Union area
15,100

Overlap

Box ABox BOverlap

Boxes are auto-scaled to fit. The y-axis increases downward, matching image pixel coordinates (origin at the top-left).

COCO threshold sweep

IoU thresholdStandardVerdict
0.50PASCAL VOC / COCO AP50No match
0.75COCO AP75 (strict)No match
0.95Near-exactNo match

Sources cited: PASCAL VOC (Everingham et al. 2010), COCO detection eval, and the Jaccard (1912) / Dice (1945) definitions. Full references below. Everything runs in your browser — nothing is uploaded.

How it works

Intersection over Union (IoU) is the standard way to measure how well two regions overlap. In object detection it scores a predicted bounding box against the ground-truth box; in segmentation and classification it compares two sets of pixels or labels. The value is always between 0 (no overlap) and 1 (perfect overlap).

Bounding-box mode follows the PASCAL VOC overlap criterion. Boxes are handled in corner form x1, y1, x2, y2 (the x, y, w, h format is normalised first as x2 = x + w, y2 = y + h). The intersection rectangle is found by taking the inner edges:

  • ix1 = max(Ax1, Bx1), iy1 = max(Ay1, By1)
  • ix2 = min(Ax2, Bx2), iy2 = min(Ay2, By2)
  • inter = max(0, ix2 − ix1) × max(0, iy2 − iy1)

The max(0, …) clamps disjoint boxes to a zero intersection rather than a negative area. Each box area is its width times its height, the union is areaA + areaB − inter, and finally IoU = inter / union. The Dice/F1 coefficient is 2·inter / (areaA + areaB), equivalently 2·IoU / (1 + IoU)— this page computes Dice both ways and confirms they agree, the credibility check behind the “verified” note.

Label-set mode computes the Jaccard index, which is IoU on sets: tokens are lower-cased and de-duplicated into sets A and B, then IoU = |A ∩ B| / |A ∪ B| and Dice = 2·|A ∩ B| / (|A| + |B|). This is the right metric for comparing predicted and true class labels, multi-label tags, or any two collections.

A detection is counted as a match when IoU ≥ the threshold. The 0.5 default is the PASCAL VOC convention; the COCO benchmark instead averages results across thresholds 0.50 to 0.95, which is why the calculator also shows the verdict at 0.50, 0.75, and 0.95 so you can see how a single pair fares across the COCO range.

Worked examples

Two overlapping boxes (corner format)

  1. Box A = [50, 50, 150, 150] → area 100 × 100 = 10,000
  2. Box B = [80, 80, 180, 180] → area 100 × 100 = 10,000
  3. Intersection corners: ix1 = max(50,80) = 80, iy1 = 80, ix2 = min(150,180) = 150, iy2 = 150
  4. inter = (150 − 80) × (150 − 80) = 70 × 70 = 4,900
  5. union = 10,000 + 10,000 − 4,900 = 15,100
  6. IoU = 4,900 / 15,100 = 0.3245 → at threshold 0.5, No match
  7. Dice = 2 × 4,900 / 20,000 = 0.4900 (matches 2·IoU/(1+IoU))

Edge case — boxes that don't touch

  1. Box A = [0, 0, 10, 10], Box B = [20, 20, 30, 30]
  2. Intersection width = max(0, min(10,30) − max(0,20)) = max(0, 10 − 20) = 0
  3. inter = 0 (clamped, not negative)
  4. union = 100 + 100 − 0 = 200
  5. IoU = 0 / 200 = 0, Dice = 0 → No match at any threshold

Label sets at the 0.5 boundary (Jaccard)

  1. Set A = {cat, dog, bird}, Set B = {dog, bird, fish}
  2. A ∩ B = {dog, bird} → |A ∩ B| = 2
  3. A ∪ B = {cat, dog, bird, fish} → |A ∪ B| = 4
  4. IoU = Jaccard = 2 / 4 = 0.5000
  5. Dice = 2 × 2 / (3 + 3) = 4 / 6 = 0.6667
  6. At threshold 0.5 → Match (0.5 ≥ 0.5 is inclusive)

Frequently asked questions

Sources & references

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 box that scored wrong, an edge case, or want polygon / rotated IoU added?

Email me at [email protected] — most fixes ship within 24 hours.