Assume a boolean array like:
1111
1111
1110
1111
1001
Now you need to find the way of arranging the least rectangles of any size to achieve this shape. So, for example, you'd find this:
+-++
| |+
| |
+-++
+ +
Where + is a corner of a rectangle and |, - borders of a rectangle.
What I thought about doing is starting with the largest possible rectangle, checking if there is any place in the array it can be placed, where every array element covered by the rectangle is true. If such a place exists, the rectangle would be added to a list. Afterwards we check in the left space of the array if there is another spot to put the rectangle in, then decrease the size of the rectangle and repeat the process with the remaining space until the size is 0.
This should yield good results since we always start with large rectangles, that we can — of course — use less of, which in turn means we are using small amounts of rectangles.
However, this is just a concept I've thought of and have not yet put into practice. It seems quite inefficient, so I was wondering if there were any known quick algorithms to achieve this?