Finding the set containing maximum empty rectangles for all the points in space

我与影子孤独终老i 提交于 2019-12-11 11:54:33

问题


Given a 2D space limited by a (white) rectangle and a set of (black) rectangles occupying that space I am looking for a way to somehow index the empty (white) space. For that purpose I would like to create a set of (white) rectangles such that for any given point in the space (point not belonging to any "black" rectangle) maximal empty rectangle exists in that resulting set of white rectangles.

Thanks


回答1:


Are you in a grid (i.e. an image) or in a continuous 2D space ? My answer is for the case where each point has integer coordinates. In the other case, you can obtain an approximation with my answer.

If I understand correctly your question, you need two things:

  1. the list of all the largest empty rectangles (that is a rectangle populated with only white points, wich cannot be extended in any direction without including a black point) (also named "maximum empty rectangles", or MER in literature).
  2. a 2D array of rectangle pointers, which indicates, for each point, the largest empty rectangle including that point. Other data structure are also possible, but I will not describe them, as the choice depends mainly on your target application requirements.

In order to compute the list, you can use an algorithm O(N), where N is the amout of pixels in the black and white image. You can find a paper describing such an algorithm at http://www.ulg.ac.be/telecom/rectangles, with some (not optimized) C++ source code. In practice, it is very fast.

In order to compute the 2D array of pinters, you need to traverse the list of all the largest empty rectangles, and for each one, to update the pointer (if necessary) for all included pixels. As there are at most N largest empty rectangles (for a prrof, see the paper linked on http://www.ulg.ac.be/telecom/rectangles), and each rectangle includes a most N pixels, this step is in worst case O(N^2). I don't know if it is possible to reduce the cost of this step.




回答2:


http://rd.springer.com/chapter/10.1007%2F3-540-53487-3_50 This paper describes an efficient approach to my problem.

Regards, Damjan



来源:https://stackoverflow.com/questions/17530847/finding-the-set-containing-maximum-empty-rectangles-for-all-the-points-in-space

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!