shapeme

Evolve images using simulated annealing

Github星跟蹤圖

Shapeme -- A small program to evolve images using simulated annealing.

This is some code I wrote 6 years ago and never released, just after I saw this insipring blog post of 2008. I remember my son having tons of fun with this, so while I rarely touched the code at all, I ran it multiple times for him, and I plan to do it again when my daughter is old enough to understand it.

Note that the program was written entirely as a trow-away, so the internal structure is not as good as it should be. However I performed some minimal refactoring after the release just to remove blatantly duplicated code, but still, far from good code.

So what it does?

  1. It takes a reference image (a PNG file).
  2. It starts with a set of random triangles and/or circles.
  3. It evolves this triangles via random mutations using some broken simulated annealing in order to evolve it into the final image.
  4. The program saves / loads states.
  5. It also outputs an SVG file representing the image, so you can print a big version of it. Sometimes generated pictures are quite cool.

Since it uses the SDL library, it shows visually the evolution of the image, and I believe this is what was so cool for my son to watch, and probably you'll have fun too.

In the release there is an example PNG you can use, the Annunziata, a painting authored by Antonello da Messina, a Sicilian painter.

Examples

This is what the program outputs with 64 triangles after a few minutes of evolution: http://antirez.com/misc/monnalisa.png

Evolved Monnalisa

How to build?

There is a terrible Makefile. Try make... It needs:

  1. The PNG lib.
  2. SDL.

How to run the program?

Basic usage using the example image:

./shapeme annunziata.png /tmp/annunziata.bin /tmp/annunziata.svg

For additional options just run the program without args, it will print some help.

Have fun!

主要指標

概覽
名稱與所有者antirez/shapeme
主編程語言C
編程語言Makefile (語言數: 2)
平台
許可證BSD 2-Clause "Simplified" License
所有者活动
創建於2014-12-07 06:22:56
推送於2022-01-14 20:15:38
最后一次提交2020-03-19 19:38:46
發布數0
用户参与
星數394
關注者數8
派生數18
提交數15
已啟用問題?
問題數5
打開的問題數2
拉請求數0
打開的拉請求數0
關閉的拉請求數1
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?