Arranges triangles in order to minimize the difference between the framebuffer and the source image.
Currently only handles PNG images.
The goal of the image decompiler is to produce:
- A list of colored semi-transparent triangles approximating a source image
- Screenshots tracking the progress of the triangle list
The process of creating the list of triangles is as follows:
- Read in parameters from user, such as source png image and maximum triangle count
- Create N primary and N secondary canvases
- Create N empty triangle lists
- Add a small triangle with random color and random position to the current most optimal list
- Set the frame counter to 0
- Create N - 1 variations of the current most optimal list. These variations are each a random 'distance' and random 'direction' away parameter-wise, and biased towards changing the most recently added triangle
- For the N primary canvases: draw the triangle lists into the canvases
- For N secondary canvases: draw the absolute value of the difference between the source image and the primary canvas into the secondary canvas
- For N secondary canvases: determine the average value of the difference (top mipmap value)
- Choose the canvas with the lowest average difference and set it as the current most optimal list
- Save a screenshot once every M minutes
- Handle user input
- Add one to the frame counter
- If the triangle list is full or the frame counter is less than F: goto 4
- goto 3
- OpenGL 4.3
- glew
- glfw3
- glm
- c++11 compiler
- cmake
- mkdir build
- cd build
- cmake .. -G "your platform"
- cd ..
- cmake --build build --config Release
- cd bin
- ./main
Optional arguments:
The source image to attempt to reproduce
-image=example.png
The image to use as each primitive
-brush=stardust.png
The maximum number of primitives
-maxPrimitives=3000
Number of simulation steps between adding a new primitive
-framesPerPrimitive=500
The opacity of each primitive
-primAlpha=0.75
Seconds between each screenshot being taken
-secondsPerScreenshot=180
Start with all primitives on-screen
-allAtOnce=true
"Concept Art: Moira" for Blizzard's Overwatch via https://playoverwatch.com/en-us/heroes/moira/ |
---|
Source |
88 Triangles |
502 Triangles |
1501 Triangles |
3000 Triangles |
Photograph by spacey @spaceUMM https://twitter.com/spaceUMM |
---|
Source |
507 Triangles |
2509 Triangles |
5003 Triangles |
10000 Triangles |
"Cities IV Deconstructed: Illustration Series" by Atelier Olschinsky via https://www.behance.net/gallery/2632147/Cities-IV-Deconstructed |
---|
Source |
79 Triangles |
251 Triangles |
509 Triangles |
1000 Triangles |
Photograph of Daft Punk by Dave Hill http://www.davehillphoto.com/ |
---|
Source |
256 Triangles |
502 Triangles |
1506 Triangles |
3000 Triangles |
Illustration by LAL!ROLE @Laxxxli https://twitter.com/Laxxxli |
---|
Source |
160 Triangles |
504 Triangles |
1508 Triangles |
3000 Triangles |