In the given implementation, the following problem occurs.
During box area computation the height, width of the box is increased by "+ 1". Thus, the size of the boxes is too large. E.g. the boxes from above get a size of 121.
The same happens in the intersection computation, which estimates the size as 100.
The resulting IoU:
IoU = 100 / (121 + 121 - 100)
IoU = 0.704
Is overestimating the actual overlap of the both boxes.
The problem is clarified. If you just scale the coordinates of your bounding boxes. While the intersection regarding the union has to stay the same. In your implementation the IoU goes up from .7 to .96. Both of the test cases below illustrate the problem.
With boundingboxes a = [0, 0, 10, 10] b = [1, 1, 11, 11]
The intersection area of both boxes is from point [1, 1] to [10, 10]. The size is 81.
Each individual box has the size of 100. The union space is defined as:
union = (area_boxA + area_boxB - intersection) union = (100 + 100 - 81) = 119
Thus, the IoU is:
IoU = intersection / union IoU = 81 / 119 IoU = 0.68
In the given implementation, the following problem occurs.
During box area computation the height, width of the box is increased by "+ 1". Thus, the size of the boxes is too large. E.g. the boxes from above get a size of 121. The same happens in the intersection computation, which estimates the size as 100.
The resulting IoU:
IoU = 100 / (121 + 121 - 100) IoU = 0.704
Is overestimating the actual overlap of the both boxes.
The problem is clarified. If you just scale the coordinates of your bounding boxes. While the intersection regarding the union has to stay the same. In your implementation the IoU goes up from .7 to .96. Both of the test cases below illustrate the problem.
`
`