Tw1ddle / geometrize-haxe

:triangular_ruler: Geometrize is a Haxe port of primitive that geometrizes images into geometric primitives
https://www.geometrize.co.uk/
Other
348 stars 31 forks source link

Algorithm Improvment proposal on the random shape generation #22

Open Cerdic opened 5 years ago

Cerdic commented 5 years ago

As a matter of fact, it is quite visible that whereas the first steps are producing large shapes to fill the larger gap between the target image and the initial one, the mean size of the found shapes is mainly decreasing.

Then I found that generating constant size shapes was a loss of computation energy:

Then you have to find a compromise and between the start of processus and the late phase. So I tried to introduce a sizeFactor in shapes:

https://github.com/Cerdic/geometrize-php/commit/f9384cafccda96d7240591ece88e2e72d2eb5c2b

Then the Model get an internal shapeSizeFactor with an initial value set to 1.0 and that is updated at each call of addShape with a low-pass filter This shapeSizeFactor is then used to init random shapes in the interesting size range:

https://github.com/Cerdic/geometrize-php/commit/1a276c87f37cad59a35abf224ca12025efc32946

This is really improving the convergence process by a much better random shape generation, and avoiding random large shapes that have a big computation cost, when not any more useful