Simplified, I have to solve the following problem:
You have a 2-dimensional array filled with 0s and 1s. Find the minimum number of rectangles such that they cover all 1s. Rectangles should not overlap.
The function signature might look like:
List<Rectangle> FindCoveringRectangles(bool[,] array)
I already have a solution that is "good enough" but doesn't always find the minimum number of rectangles. I'd like to know if there is some well known and efficient algorithm that can be applied to solve this problem?
Example:
An input array of:
..........
.1.....11.
.......11.
...111....
...111....
...111....
....1111..
....1111..
......11..
..........
(0s replaced by dots for readability)
Might result in the following rectangles:
(2,2,2,2),
(2,8,3,9),
(4,4,6,6),
(7,5,8,8),
(9,7,9,8)
(top, left, bottom, right), 1-based
There can be more than one solution, but one is enough.