Intersection over Union for detection
the core overlap metric.
IoU is the area of overlap divided by the area of union of predicted and ground-truth boxes; a threshold decides true positives.
What's really being asked
Whether you understand the fundamental spatial agreement metric that makes detection evaluation and post-processing possible.
The full answer
Intersection over Union measures how well a predicted bounding box overlaps a ground-truth box. You compute the area of their intersection, the overlapping rectangle, and the area of their union, the total area covered by either box, then divide intersection by union. The result ranges from zero, no overlap, to one, perfect alignment. IoU is critical because detection produces boxes that rarely match ground truth exactly, so you need a continuous measure of agreement and a rule for deciding a hit. A prediction is counted a true positive when its IoU with a ground-truth box meets or exceeds a chosen threshold, commonly zero point five. IoU is also the criterion in non-maximum suppression, where overlapping duplicate boxes above an IoU threshold are pruned, and it defines the matching in mAP computation.
The mistakes people make
Dividing intersection by the predicted box area only, which is a different metric. Forgetting that union subtracts the double-counted intersection. Treating IoU as binary rather than continuous. Not mentioning the threshold that turns IoU into a true or false positive decision.
What usually comes next
How does IoU feed into non-max suppression. Why does COCO average over multiple IoU thresholds. What are limitations of IoU that GIoU or DIoU address. How do you compute union from the two areas.
A concrete example
A predicted box and a ground-truth box each cover one hundred square pixels and overlap in fifty square pixels. The union is one hundred plus one hundred minus fifty, which is one hundred fifty, so IoU is fifty over one hundred fifty, about zero point three three. At a zero point five threshold this prediction would be a false positive despite real overlap, illustrating how the threshold sets the strictness of what counts as a correct detection.
Interview question
How is Intersection over Union computed for a predicted and ground-truth bounding box?
- a.Intersection area divided by the predicted box area
- b.Union area divided by the intersection area
- c.Intersection area divided by the union of both boxes' areasCorrect
- d.The distance between the two box centers
Why? this is the answer
IoU divides the overlapping area by the combined area of both boxes, ranging zero to one. Dividing by only the predicted area, inverting the ratio, or using center distance all describe different, incorrect metrics.
Just read this? Test yourself on what you have been reading.
Read the original → en.wikipedia.org
- #computer-vision
- #iou
- #object-detection
- #evaluation-metric
- #bounding-box
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on computer-vision — each one lists the topics its interview covers.
See open roles