So we have some complicated shape A which we want to approximate with the union of up to N grid-aligned (x/y axis) rectangles, which we'll call B.
For simplicity let's say A is rendered to a bitmap. This also means that rectangle corners will be on lattice points.
The metric I originally wanted to use and minimize was the area of A XOR B, but we could use another.
I'm guessing this is NP, and for my purposes a fast approximation will suffice. The generated rectangle set should be within some amount of the optimal solution.