Hello!
Concerning Week 3 Exercise 2 (IoU computation)
I am having some trouble understanding how the bounding boxes are encoded for IoU computation.
On one hand, in the exercise instructions it is specified how x1, y1 is the top left of the image:

Then, in the additional hints:
It says that to get the top left coordinates for the Intersection box, we should compute the maximum of the y1 coordinates for the boxes.
Maybe I am making a trivial mistake in understanding this, but if y1 represent the top left y coordinate, should this be the minimum if the y1’s ? (And for the bottom corner yi2 the maximum of y2’s ?)
If in the code I follow the hints, it works.
But, the reason why it seems to work is that in the testing code, the boxes’ coordinates are defined as follows:
(box1_x1, box1_y1, box1_x2, box1_y2) = box1
(box2_x1, box2_y1, box2_x2, box2_y2) = box2
Meaning that the coordinate y1 (top left according to description) is smaller than y2 (bottom right according to the description). So the top is below the bottom?
Can anyone help me understand what am I missing?
Thank you!!
The key point in understanding this is the convention used for the coordinate system for images. It’s not the normal Euclidean orientation. (0,0) is the upper left and (1,1) is the lower right. So for the vertical dimension, smaller values are higher on the image. This is explained in the text.
With that in mind, think about what “intersection” means: a point needs to be in both rectangles. So that means that it must be below and to the right of the upper left corner of both boxes. If the y values increase as you go down, then to be below both upper left corners, the value will need to be at least as big as each of the y values of the corners, right? That would be the max of the values, wouldn’t it?
1 Like
Got it thanks!
My misunderstanding was that not only inside a box but also for the whole image the axis origin (0,0) is on the top left and y increases as you go down. Now it adds up. Thanks!
2 Likes
Here’s something pulled from my way back machine…I posted this originally some 5 years ago, but this is the second question on it this week. Hope it helps
@picnic
EDIT
Related thread here : Car detection with YOLO xi1 yi1
3 Likes