Algorithm to split an image into smaller images reducing the amount of whitespace and specifying maximum amount of rectangles
I am looking for an algorithm which can split an image into smaller images, with some constraints. One constraint is to use the least amount of "whitespace" meaning empty pixels. And the other is to specify a maximum amount of images to split it into. For example lets look at the below image. There is a lot of "whitespace" in it. I would like to divide this images into a few other images so i can reduce the amount of memory this image occupies, and also to reduce the amount of "drawing" this image will take. .=transparent pixel x=colored pixel .................... .xxxxxxxxxxx........ ...xxxx.