Skip to content
/ primopt Public

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

License

Notifications You must be signed in to change notification settings

dyf/primopt

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages