【发布时间】:2015-10-22 20:39:27
【问题描述】:
我在图像中生成了很多边界框。如何合并图像中的重叠边界框?
例如,
_________________ ________________________
| | | |
| —————————|———— | |
| | | | | |
———————|—————————— | ——> | |
| | | |
| ————————|—————— | |
—————|———————— | | |
| | | |
| | | |
———————————————— ________________________
我知道使用rectangle 1 | rectangle 2 来生成一个新的矩形。
它可以通过以下方法检测并合并它们。(来自Efficient way to combine intersecting bounding rectangles)
if((rect1 & rect2) == rect1) ... // rect1 is completely inside rect2; do nothing.
else if((rect1 & rect2).area() > 0) // they intersect; merge them.
newrect = rect1 | rect2;
... // remove rect1 and rect2 from list and insert newrect.
但是我的意思是当三个或四个矩形重叠时如何判断哪个矩形重叠。我虽然可以使用重叠区域来判断它们是否重叠。
还有其他有效的方法吗? 非常感谢。
【问题讨论】:
标签: image opencv image-processing