0

Perhaps this is more computational geometry, but here goes:

I have a 2D SDF describing my shape, but it's fine to think of it as a black/white image (black="inside" white="outside").

I want to generate a small set of rectangles (say, 8 of them) covering the image, which are allowed to overlap, and which minimize the amount of error. Error would be any leftover "black" areas of the image that are not covered.

The image could be convex, have holes, etc. It is general.

I realize that minimal rectangle covering is NP-hard, though that's not exactly what I'm asking for: I'm asking for minimizing error given a finite set of rectangles to work with. Maybe it's just as hard though; not sure.

Anyway, I do not need to find the perfect solution; decent heuristics would be fine.

I could imagine some pretty general "greedy search" traversal of the state space, but wondered if there were any tricks anyone knows of.

Aside: I've also looked at several papers for "rectangular decomposition", and "minimal dissection", but those problems generally assume I want disjoint rectangles. Disjoint would be okay, but really I want maximal coverage while allowing overlap.

Edit Here is an example:

Target image:

target image

Covering with 4 rectangles (red, green, blue, yellow):

covered image

Any uncovered black pixels are the "error". No white pixels are allowed to get covered.

jwd
  • 133
  • 5
  • So you want to fill a shape with the minimum amount of rectangles, as internally as possible. Overlap is ok. You also happen to have this shape as an SDF already. Do these need to be axes aligned rectangles or can they be oriented? – Andrew Wilson Feb 03 '21 at 01:46
  • @AndrewWilson: I added an image to clarify. Generally what you say is true, but I would amend "as internally as possible" to be "the covering rects must not spill out of the 'black' area" (so "fully internally"?). Yes, they do need to be axis-aligned. – jwd Feb 03 '21 at 02:04

0 Answers0