且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从列表中查找和删除图像的重叠切片?

更新时间:2023-12-05 15:45:04

显然您可以采用O(n ^ 2)方法检查每个blob与所有其他blob,并通过检查是否 blob1.dx.start>确定是否应该删除它。 blob2.dx.start和blob1.dy.start> blob2.dy.start和blob1.dx.stop< blob2.dx.stop和blob1.dy.stop< blob2.dy.stop (如果此条件为真,则可以从列表中删除blob1)。如果您的总blob数量非常低,除非我遗漏了某些内容,否则这应该有效。

Obviously you can take an O(n^2) approach that checks each blob against all other blobs and determines if it should be removed by checking if blob1.dx.start > blob2.dx.start and blob1.dy.start > blob2.dy.start and blob1.dx.stop < blob2.dx.stop and blob1.dy.stop < blob2.dy.stop (if this condition is true, it is ok to remove blob1 from the list). If your total blob count is pretty low, this should work unless I am missing something.

如果您正在寻找优化的解决方案,那么了解如何有很多斑点,条件有多常见。

If you are looking for an optimized solution, it would be helpful to know about how many blobs there are and how common the condition is.