简体   繁体   中英

Plus one in calculating area of rectangle

areas = (end_x - start_x + 1) * (end_y - start_y + 1)

Above is what use in calculating area of rectangle for non-max-suppression in two different links below, why there is a need for plus one?

https://github.com/amusi/Non-Maximum-Suppression/blob/master/nms.py https://www.pyimagesearch.com/2014/11/17/non-maximum-suppression-object-detection-python/

I guess that plus one is just used to get the exact area. For example, width begin in pixel 2, end in pixel 4. The exact width is 3 (pixel 2, 3, 4). A 3 equals to 4 - 2 + 1.

But in my opion, it's not essential to care about that. Just make sure you cal every area in the same standard.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM