Skip to content

Latest commit

 

History

History
33 lines (23 loc) · 1.37 KB

README.md

File metadata and controls

33 lines (23 loc) · 1.37 KB

primopt

PRimitive IMage OPtimizer

Compose an image from random primitives (circles, triangles, ellipses, etc).

Or: personal challenge to see how quickly I could hack something like https://github.com/fogleman/primitive together in python.

Elliptical Swedish Chef

Swedish Chef in Ellipses

Triangular Beaker

Beaker in Triangles

Rectangular Beaker

Beaker in Triangles

Hexagonal Animal

Animal in Hexagons

Curvy Kermit

Curvy Kermit

Statler and Waldorf Crescents

Statler and Waldorf Crescents

Pseudocode

  1. Pick M random circles (position, size) with random alpha and random color chosen from input image
  2. Pick the circle that has minimal RMSE error when blended into current canvas
  3. Stochastic hillclimb: mutate that circle N times, choosing new circle if it has lower error
  4. Blend best shape into canvas
  5. Repeat
  6. Optionally: start 1-5 at an aggressively subsampled image resolution and use low-res primitives to seed the higher resolutions