npinto/felzenszwalb_cvpr2008 — comment on commit df4860c14a8714be9c3294c814b5fbba7593a2a0
File: nms.m line 35
By npinto:

Let's see if we can formulate a simple example where using ```o = w * h / area(j)``` is inconsistent. Note that ```area(j)``` is the area of the bbox under consideration in the inner loop.

Notations:

* ```higher_confidence_bbox``` is the ``i``th bbox (in the outer loop)
* ```lower_confidence_bbox``` is the ``j``th bbox (in the inner loop)

Scenario 1, higher_confidence_bbox is "in" lower_confidence_bbox and we pose:

```
area(higher_confidence_bbox) = 2 * 4 = 8
area(lower_confidence_bbox) = 6 * 10 = 60
intersection_area(higher_confidence_bbox, lower_confidence_bbox) = 2 * 4 = 8
union_area(higher_confidence_bbox, lower_confidence_bbox) = \
area(higher_confidence_bbox) + area(lower_confidence_bbox) \
- intersection_area(higher_confidence_bbox, lower_confidence_bbox) = 60
```

We get ```w * h / area(j) = intersection_area / area(lower_confidence_bbox) = 8 / 60 << 1``` and likely to **not** "suppress" the lower_confidence_bbox.

Scenario 2, lower_confidence_bbox is "in" higher_confidence_bbox and we have:

```
area(higher_confidence_bbox) = 6 * 10 = 60
area(lower_confidence_bbox) = 2 * 4 = 8
(note the flip from scenario 1)
(same intersection_area(...) and union_area(...))
```

We get ```w * h / area(j) = intersection_area / area(lower_confidence_bbox) = 8 / 8 = 1``` which will "suppress" the lower_confidence_bbox.

Conclusions: both scenarios are supposed to yield the same outcome (?) but don't, using ```overlap = intersection_area / union_area``` solves this issue.