Algorithm to split an image into smaller images reducing the amount of whitespace and specifying maximum amount of rectangles

后端 未结 5 978
悲哀的现实
悲哀的现实 2021-01-03 01:08

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

5条回答
  •  伪装坚强ぢ
    2021-01-03 02:00

    I would look at doing it recursively, each time splitting in half or into four, until you get to the level you want (for you 2 -> 4^2 = 16). At the bottom level check for empty squares and discard them. Of course this gives you a grid of rectangles proportional to the shape of the original image, rather than optimally placed rectangles, but it might start you off on the right track.

提交回复
热议问题