{"id":24432166,"url":"https://github.com/akilmarshall/procedural-image-generation","last_synced_at":"2026-04-21T16:03:03.453Z","repository":{"id":37700471,"uuid":"497248139","full_name":"akilmarshall/procedural-image-generation","owner":"akilmarshall","description":"Experiments in the procedural generation of tiled images.","archived":false,"fork":false,"pushed_at":"2022-07-07T21:01:40.000Z","size":302,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-20T15:47:20.666Z","etag":null,"topics":["image-generation","image-processing","procedural-generation","python3","rust-lang"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akilmarshall.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-28T07:37:42.000Z","updated_at":"2022-06-29T23:58:28.000Z","dependencies_parsed_at":"2022-07-12T00:01:06.193Z","dependency_job_id":null,"html_url":"https://github.com/akilmarshall/procedural-image-generation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akilmarshall%2Fprocedural-image-generation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akilmarshall%2Fprocedural-image-generation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akilmarshall%2Fprocedural-image-generation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akilmarshall%2Fprocedural-image-generation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akilmarshall","download_url":"https://codeload.github.com/akilmarshall/procedural-image-generation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243475366,"owners_count":20296712,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["image-generation","image-processing","procedural-generation","python3","rust-lang"],"created_at":"2025-01-20T15:34:36.566Z","updated_at":"2025-12-29T16:53:05.156Z","avatar_url":"https://github.com/akilmarshall.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Procedural Image Generation\n\nHow can I turn a single image into more images that are somewhat like it?\n\n## Todo\n\n- implement tile sheet dump [rust]\n- implement neighbor function visual dump [rust]\n- write code to make animated gifs from MCI algorithms\n\n## Constrained Backtracking Search\n\n(this example uses [this](https://imgur.com/uFuMFEU.png) image as input)\n\nAlso known as [Wave Function Collapse](https://github.com/mxgmn/WaveFunctionCollapse) (tiled model)\n\nWhen 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\nwith a \"seeded\" image:\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=https://imgur.com/3JFRd9e.png/\u003e\n--\u003e\n\u003cimg src=https://i.imgur.com/WEzHzLh.gif/\u003e\n\u003c/p\u003e\n\u003cp align = \"center\"\u003e5x5 fix (3, 3) with the door tile\u003c/p\u003e\n\nThis 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.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=https://imgur.com/Ow7uHy0.png/\u003e\n--\u003e\n\u003cimg src=https://imgur.com/vZ4Mdo9.gif/\u003e\n\u003c/p\u003e\n\u003cp align = \"center\"\u003e5x5 fix several bike paths\u003c/p\u003e\n\nI 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.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=https://imgur.com/L7LUl8O.png/\u003e\n--\u003e\n\u003cimg src=https://imgur.com/oPeLdEJ.gif/\u003e\n\u003c/p\u003e\n\u003cp align = \"center\"\u003e5x5 fix (3, 3) with a mud slide tile\u003c/p\u003e\n\nI 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.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=https://imgur.com/hPRPo53.png/\u003e\n--\u003e\n\u003cimg src=https://imgur.com/6fZAtow.gif/\u003e\n\u003c/p\u003e\n\u003cp align = \"center\"\u003e4x4 fix corner lake tiles\u003c/p\u003e\n\nI wanted to see what the algorithm was able to come up with given minimal input and I am quite pleased with the output.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=https://imgur.com/wImRKv5.png/\u003e\n--\u003e\n\u003cimg src=https://imgur.com/rvpEqSP.gif/\u003e\n\u003c/p\u003e\n\u003cp align = \"center\"\u003e14x5 fix several corner roof tiles\u003c/p\u003e\n\nI 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.\n\n\n## Examples\n\nUsing the following image as input \n\n\u003cp align=\"center\"\u003e\n\u003cimg src=https://imgur.com/ZuOinkm.png/\u003e\n\u003c/p\u003e\n\u003cp align = \"center\"\u003eminimal input example\u003c/p\u003e\n\nMade up of the following [tileset](https://github.com/akilmarshall/procedural-image-generation/wiki/Theory)\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=https://imgur.com/CfTFzSk.png/\u003e\n\u003c/p\u003e\n\nIt's [neighbor functions](https://github.com/akilmarshall/procedural-image-generation/wiki/Theory#neighbor-function) are visualized below\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=https://imgur.com/GQAaMIr.png/\u003e\n\u003c/p\u003e\n\n\n### [Fragment](https://github.com/akilmarshall/procedural-image-generation/wiki/Procedures#fragment)\n\nFor this incredibly minimal input image each algorithm produced only 10 outputs\neach. Each algorithm was able to produce the original image, in fact each algorithm\nproduced the exact same output. This is not to be expected and is perhaps an\nartifact of the simplicity of the input image, the exact reasons are currently unknown.\n\nThe images are in no particular order.\n\n#### [CENTER](https://github.com/akilmarshall/procedural-image-generation/wiki/CENTER-algorithm)\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=https://imgur.com/0fcqyXN.png/\u003e\n\u003c/p\u003e\n\u003cp align = \"center\"\u003eCENTER algorithm output\u003c/p\u003e\n\n#### [CORNER](https://github.com/akilmarshall/procedural-image-generation/wiki/CORNER-algorithm)\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=https://imgur.com/pXQtAjm.png\u003e\n\u003c/p\u003e\n\u003cp align = \"center\"\u003eCORNER algorithm output\u003c/p\u003e\n\n#### [SIDE](https://github.com/akilmarshall/procedural-image-generation/wiki/SIDE-algorithm)\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=https://imgur.com/dZEUcL5.png\u003e\n\u003c/p\u003e\n\u003cp align = \"center\"\u003eSIDE algorithm output\u003c/p\u003e\n\n### [Minimum Conformity Improvement](https://github.com/akilmarshall/procedural-image-generation/wiki/Minimum-Conformity-Improvement)\n\n1. Begin with an image\n2. 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))\n3. change it's neighbors to tiles from it's neighbor sets (force conformity)\n4. goto 2\n\nSeveral runs of this naive algorithm produce the following select output\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=https://imgur.com/MYrgU01.png\u003e\n\u003c/p\u003e\n\u003cp align = \"center\"\u003e10x10 fitness score 50\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=https://imgur.com/5L3a8Ch.png\u003e\n\u003c/p\u003e\n\u003cp align = \"center\"\u003e10x10 fitness score 220\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=https://imgur.com/3G4ylRZ.png\u003e\n\u003c/p\u003e\n\u003cp align = \"center\"\u003e10x10 fitness score 130\u003c/p\u003e\n\nA **perfect** image would have a score of 400.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakilmarshall%2Fprocedural-image-generation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakilmarshall%2Fprocedural-image-generation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakilmarshall%2Fprocedural-image-generation/lists"}