我有一个1920 x 1080
的图像,以及相应的坐标,它们表示图像上具有随机形状(x,y)的边界框
bb_rects= [[412, 130, 507, 234], [521, 82, 647, 188], [521, 314, 747, 469], [820, 372, 943, 473]]
我正在尝试从1920 x 1080
中提取不在bb_rects
中那些边界框内的100 x 100图像。我在1920 x 1080
图像上使用蛮力,每100步用一个窗口提取100x100
坐标。如何排除all_rects
中与bb_rects
中的坐标重叠的坐标
all_rects= [(0, 0, 100, 100), (100, 0, 200, 100), (200, 0, 300, 100), (300, 0, 400, 100), (400, 0, 500, 100), (500, 0, 600, 100), (600, 0, 700, 100), (700, 0, 800, 100), (800, 0, 900, 100), (900, 0, 1000, 100), (1000, 0, 1100, 100), (1100, 0, 1200, 100), (1200, 0, 1300, 100), (1300, 0, 1400, 100), (1400, 0, 1500, 100), (1500, 0, 1600, 100), (1600, 0, 1700, 100), (1700, 0, 1800, 100), (1800, 0, 1900, 100), (0, 100, 100, 200), (100, 100, 200, 200), (200, 100, 300, 200), (300, 100, 400, 200), (400, 100, 500, 200), (500, 100, 600, 200), (600, 100, 700, 200), (700, 100, 800, 200), (800, 100, 900, 200), (900, 100, 1000, 200), (1500, 900, 1600, 1000), (1600, 900, 1700, 1000), (1700, 900, 1800, 1000), (1800, 900, 1900, 1000)]
输出应该是rects_filtered
,它们是all_rects
坐标,与bb_rects
不重叠
所以,我想到的是:这个概念是建立一种“网格”,并确定哪些正方形实际上完全包含在任何一个bb_矩形中。不确定它在处理时间方面是否更好,但您可能希望尝试以下方法:
对于我的测试数据,它产生:
您可以稍后简单地过滤掉“所有错误”
注意:代码当然应该重构。这只是一个快速原型
相关问题 更多 >
编程相关推荐