# Intersection Over Union / Bounding Box for multiple bounding boxes in an image

My image has 4 ground truth bounding boxes and the prediction just has 3 bounding boxes

• I need to calculate the quality of bounding boxes predicted.

I know how to calculate IoU / IoBB for 2 bounding boxes ( 1 pred and 1 ground )

But whats the algorithm to decide which pair to calculate for?

Would it be correct to calculate it for all pairs of prediction/ground truth exhaustively?

I am a bit confused here

• Can you answer it if you were able to figure it out? Commented Oct 8, 2019 at 15:41
• I have also come across this problem now but don't know what is the right approach. I was thinking of going through each bounding box in the ground truth file and calculate the area if there is an intersection with a bounding box in the prediction file. Don't know if there is a better approach. @SyedSaad Were you able to figure out a feasible approach? Commented May 9, 2021 at 20:36

Yes, normally IoU is calculated for all possible pairs within an image. Then the ones with the highest IoU score are selected. You can take a look at this code if you are not sure how to implement that.

• I think this approach somewhat mirrors that of Non-Maximum Suppression, but in some interpretations and scenarios it can be said to grossly under-represent the false positive nature of weakly and non-contributing detections. Commented Dec 2, 2023 at 2:01