Fill an area with as few rectangles as possible Saying I have shapes like these (made of a finite number of elementary 1cm*1cm squares):

Is there any algorithm to apply so I can fill these shapes with the least amount fo rectangles (besides listing all the fillings I could do and take the one with less rectangles)?
And what if the shape as holes in it?
All I found so far are just "be smart", but I would like to be able to let a computer do that. Thanks for the tips!
Image from http://static.studyladder.com/cdn/course/b3/2b1e1e9d0ed0.jpg
 A: Not really an answer (or maybe yes), but too long for a comment.
It is important the filling to be minimal? If not, you can do the following.


*

*Begin at any tile of the figure. Consider this a rectangle of size 1.

*For each direction (N, S, E, W) enlarge the rectangle in that direction.

*If the new rectangle is contained in the figure, keep the change. Otherwise, discard it and try other direction.

*If the rectangle can't be enlarged anymore in any direction, remove it from the figure and append the data of the rectangle in some array to store it. Otherwise return to step 2.

*Repeat from 1 until the figure is totally removed.


I have tried some examples (by hand) and the results seems good.
A: This section of the "Polygon covering" page in Wikipedia
implies that brute-force trial and error
(generating all the partitions into rectangles and taking the one
with the fewest rectangles)
is the best you can do in general.
The problem I think you're describing is $NP$-hard.
But the $NP$-hardness of a problem often describes only the
worst-case times due to some pathological cases.
The figures you gave as examples look relatively "nice."
You could use some heuristics to make the algorithm try large rectangles
in cases such as these, which would often lead it to find the minimal
covering quickly; you then might use some "branch and bound" method
to quickly rule out all other possible coverings.
For example, once you have found a covering with $n$ rectangles,
when you are searching for another covering and have already put
$n-1$ rectangles in the covering without completing it, you can
rule out all the coverings that include those $n-1$ rectangles.
This could very quickly eliminate large portions of your search space.
