Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/akilmarshall/procedural-image-generation
Experiments in the procedural generation of tiled images.
https://github.com/akilmarshall/procedural-image-generation
image-generation image-processing procedural-generation python3 rust-lang
Last synced: about 9 hours ago
JSON representation
Experiments in the procedural generation of tiled images.
- Host: GitHub
- URL: https://github.com/akilmarshall/procedural-image-generation
- Owner: akilmarshall
- Created: 2022-05-28T07:37:42.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-07-07T21:01:40.000Z (over 2 years ago)
- Last Synced: 2023-03-05T16:20:50.000Z (almost 2 years ago)
- Topics: image-generation, image-processing, procedural-generation, python3, rust-lang
- Language: Python
- Homepage:
- Size: 295 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Procedural Image Generation
How can I turn a single image into more images that are somewhat like it?
## Todo
- implement tile sheet dump [rust]
- implement neighbor function visual dump [rust]
- write code to make animated gifs from MCI algorithms## Constrained Backtracking Search
(this example uses [this](https://imgur.com/uFuMFEU.png) image as input)
Also known as [Wave Function Collapse](https://github.com/mxgmn/WaveFunctionCollapse) (tiled model)
When tasked with completing a blank image this algorithm's run time and output is enormous (2x2 and sometimges 3x3 can be computable). It is often more interesting to provide it
with a "seeded" image:
-->
5x5 fix (3, 3) with the door tile
This door tile only appears once in the original image thus a large portion of the image space is constrained, however an enormous amount of variety is still observed in the outputs.
-->
5x5 fix several bike paths
I was curious to see what would happen with the bike paths. In this example their generation is more constrained then I expected but this may not hold up to further testing.
-->
5x5 fix (3, 3) with a mud slide tile
I wanted to see what kind of areas could be placed around the mud slide. I expected that the path in and out would be fairly constrained and the left and right allowed to vary wildly, it was in fact the opposite.
-->
4x4 fix corner lake tiles
I wanted to see what the algorithm was able to come up with given minimal input and I am quite pleased with the output.
-->
14x5 fix several corner roof tiles
I wanted to test building a larger image leaning on the algorithm to fill in large areas. Initially I believed that sucessively building an image and feeding larger and larger inputs would be the work flow, however this only increasese the search space over "every" (read many) variation which is theoritically comforting but practically useless. Edge exapnding and filling in small areas with fixed sections feels like the correct way to use this tool.
## Examples
Using the following image as input
minimal input example
Made up of the following [tileset](https://github.com/akilmarshall/procedural-image-generation/wiki/Theory)
It's [neighbor functions](https://github.com/akilmarshall/procedural-image-generation/wiki/Theory#neighbor-function) are visualized below
### [Fragment](https://github.com/akilmarshall/procedural-image-generation/wiki/Procedures#fragment)
For this incredibly minimal input image each algorithm produced only 10 outputs
each. Each algorithm was able to produce the original image, in fact each algorithm
produced the exact same output. This is not to be expected and is perhaps an
artifact of the simplicity of the input image, the exact reasons are currently unknown.The images are in no particular order.
#### [CENTER](https://github.com/akilmarshall/procedural-image-generation/wiki/CENTER-algorithm)
CENTER algorithm output
#### [CORNER](https://github.com/akilmarshall/procedural-image-generation/wiki/CORNER-algorithm)
CORNER algorithm output
#### [SIDE](https://github.com/akilmarshall/procedural-image-generation/wiki/SIDE-algorithm)
SIDE algorithm output
### [Minimum Conformity Improvement](https://github.com/akilmarshall/procedural-image-generation/wiki/Minimum-Conformity-Improvement)
1. Begin with an image
2. Select the tile with the least [conformity](https://github.com/akilmarshall/procedural-image-generation/wiki/Genetic-Algorithms#conformity-function) (halt if all conforming or [done](https://github.com/akilmarshall/procedural-image-generation/wiki/Minimum-Conformity-Improvement#termination))
3. change it's neighbors to tiles from it's neighbor sets (force conformity)
4. goto 2Several runs of this naive algorithm produce the following select output
10x10 fitness score 50
10x10 fitness score 220
10x10 fitness score 130
A **perfect** image would have a score of 400.