Suppose that I open up MS Paint, draw a bunch of solid rectangles, save it as a png, and give it to you:
Now you have to find out how I drew these rectangles. For this image, your algorithm would generate instructions like,
- Draw the green rectangle (filling up the entire space)
- Draw the pink rectangle
- Draw the yellow rectangle
- Draw the blue rectangle
Or in other words, given an image, I want to generate it using the fewest rectangle commands as possible. A rectangle command draws a solid rectangle given its position, length, width, and color. How can I approach this problem?
The algorithm should be robust enough to process images not only drawn by placing rectangles, but also complex images like photographs.