IoU Calculator
Compute Intersection over Union for two bounding boxes
IoU Calculator — Intersection over Union
Intersection over Union (IoU), also called the Jaccard index, is the standard metric for evaluating object detection models. It measures the overlap between a predicted bounding box and a ground truth bounding box. An IoU of 1.0 means perfect overlap, and 0 means no overlap at all.
How to Use This Calculator
- Box A — enter the four coordinates of the first bounding box as x1, y1 (top-left corner) and x2, y2 (bottom-right corner).
- Box B — enter the coordinates of the second bounding box in the same format.
- The calculator shows IoU, intersection area, union area, and individual box areas instantly.
The IoU Formula
IoU = Area of Intersection / Area of Union
Area of Union = Area(A) + Area(B) - Area of Intersection
Coordinates follow the (x1, y1, x2, y2) format where (x1, y1) is the top-left corner and (x2, y2) is the bottom-right corner. This is the most common format in frameworks like PyTorch and TensorFlow.
IoU Thresholds in Object Detection
- IoU ≥ 0.5: Standard PASCAL VOC threshold — a detection is considered correct if IoU with ground truth exceeds 0.5.
- IoU ≥ 0.75: COCO strict threshold — used in the COCO benchmark for more precise localization.
- IoU = 0.5 to 0.95 (COCO mAP): The COCO primary metric averages AP over IoU thresholds from 0.50 to 0.95 in steps of 0.05.
- IoU < 0.5: Typically considered a missed detection (false negative) in standard benchmarks.
Applications of IoU
Object detection evaluation: YOLO, Faster R-CNN, SSD, and other detectors use IoU to determine whether a predicted box matches a ground truth box.
Non-maximum suppression (NMS): During inference, IoU is used to eliminate duplicate detections — if two boxes have IoU above a threshold, only the one with the higher confidence score is kept.
Segmentation evaluation: IoU is applied to binary masks (pixel sets) in semantic and instance segmentation, where intersection and union are computed over pixel sets instead of rectangles.
Anchor box design: When designing anchor boxes for anchor-based detectors, IoU is used to select scales and aspect ratios that maximize overlap with ground truth boxes in the training set.