Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python photo mosaic with abstractly shaped mosaics

Image mosaics use a set of predefined squared images to build a larger image (example here). There are a lot of solutions and it's quite trivial to achieve this effect. However, it becomes much harder with the following constraints:

  1. The shape of the original mosaics is abstract. Any convex polygon could do.
  2. Each mosaic can only be used once.
  3. There is no need for the mosaics to be absolutely packed (i.e. occupying 100% of the canvas), but they should be as packed as possible without overlapping.

I'm trying to automatize the ancient art of tesselation, specifically the Opus palladianum technique.

My idea is to use simulated annealing or some other heuristic to optimize the position and rotation of each irregular mosaic, swaping two in each iteration, trying to minimize some energy function that reflects the similarity to the target image as well as the "packness" of the tiles. I'm trying to achieve this in python, any ideas and help would be greatly appreciated.

Example:

enter image description here

like image 964
Anoyz Avatar asked Jun 18 '17 16:06

Anoyz


1 Answers

I expect that you may probably use GA (Genetic Algorithm) with a "non-overlapping" constraint to do this job.

Parameters for individual (each convex polygon) are:

  • initial position
  • rotation
  • (size ?)

And your fit function will be build to give best note to each individual when polygon are not overlapping (and close to other individual)

You may see this video and this one as example.

Regards

like image 174
A STEFANI Avatar answered Sep 28 '22 09:09

A STEFANI