{"id":21045738,"url":"https://github.com/zionc27/computational-art-with-genetic-algorithm","last_synced_at":"2026-05-17T02:37:18.225Z","repository":{"id":211840007,"uuid":"729638005","full_name":"ZionC27/Computational-Art-with-Genetic-algorithm","owner":"ZionC27","description":"Genetic algorithm to iteratively generate an image resembling an original image","archived":false,"fork":false,"pushed_at":"2023-12-15T01:25:36.000Z","size":16320,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-20T17:48:45.343Z","etag":null,"topics":["genetic-algorithm","numpy","photography","pillow-library","python"],"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/ZionC27.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-09T21:27:48.000Z","updated_at":"2024-03-31T21:42:57.000Z","dependencies_parsed_at":"2025-01-20T17:52:53.559Z","dependency_job_id":null,"html_url":"https://github.com/ZionC27/Computational-Art-with-Genetic-algorithm","commit_stats":null,"previous_names":["zionc27/computational-art-with-genetic-algorithm"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZionC27%2FComputational-Art-with-Genetic-algorithm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZionC27%2FComputational-Art-with-Genetic-algorithm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZionC27%2FComputational-Art-with-Genetic-algorithm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZionC27%2FComputational-Art-with-Genetic-algorithm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZionC27","download_url":"https://codeload.github.com/ZionC27/Computational-Art-with-Genetic-algorithm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243489758,"owners_count":20299001,"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":["genetic-algorithm","numpy","photography","pillow-library","python"],"created_at":"2024-11-19T14:24:58.213Z","updated_at":"2026-05-17T02:37:13.193Z","avatar_url":"https://github.com/ZionC27.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Computational-Art-with-Genetic-algorithm\n\n\nThis project employs a genetic algorithm to iteratively generate an image resembling an original image. The methodology involves several key steps and processes:\n\n## Methodology Overview\n\n### A. Population Creation\n- Chromosomes encapsulate genes representing circles to be drawn on the canvas.\n- Initial creation of chromosomes involves random values for X, and Y coordinates, radius of the circle, and HSL values. ()\n- Flexibility allows adjusting the number of circles and population size for experimentation.\n\n### B. Drawing the Image\n- Utilizes extracted genes to draw circles based on their parameters.\n- Maps 1 or 0 values to appropriate HSL parameters, radius, and coordinates.\n- Dynamic adjustment of radius for optimal outcomes.\n\n### C. Fitness Function\n- Compares original and generated images pixel-wise.\n- Utilizes Root Mean Square Error (RMSE) for quantifying image similarity.\n- Provides a fitness score indicating proximity between the images.\n\n### D. Generation Loop\n- Sorts chromosomes based on fitness, retains top performers and discards the lower half.\n- Periodically stores populations to a JSON file for progress backup.\n- Executes crossover and mutation functions for subsequent generations.\n\n### E. Crossover\n- Randomly selects parent chromosomes and performs uniform crossover for gene swapping.\n\n### F. Mutation\n- Operates on genes within chromosomes, introducing alterations based on assigned probabilities.\n- Allows changes in coordinates, radius, and HSL values with adjustable magnitudes.\n- Includes addition or deletion of genes, favoring a higher chance of adding new genes.\n\n## Conclusion\nThis algorithmic approach aims to progressively generate an image resembling the original by refining circles' attributes using genetic operations like crossover and mutation. The fitness function enables efficient evaluation, guiding the iterative process towards image resemblance.\n\n\n## Requirements to run: \nPython: version 3.9 and above should work\n\nPillow (PIL): version 10.1.0 and above can be installed with\n```\npip install Pillow\n```\nNumpy: version1.22 and above can be installed with\n```\npip install numpy\n```\n\n## File structure\n**Main.py**: used to start the initial run, choose a PNG image, put it in the same directory, find \"FILENAME\" in the code, change your filename.png, and run.\n\n**Main_ct.py**: used to continue running if the program is stopped. To continue find \"FILENAME\" in the code and change it to your filename.png then find the last generated image number and enter it at \"start_offset = \" and run.\n\n**output.py**: used to display the best 5 images find \"FILENAME\" in the code and change your filename.png then run.\n\n## Notes \n\nThe image file must be a PNG.\n\nConstants and values \n```\n  POPULATION_SIZE\n  GENERATIONS\n  NUMBER_CIRCLES\n  UNIFORM_CROSSOVER_PROB\n  MUTATION_X_Y_AMOUNT\n  MUTATION_RADIUS_AMOUNT\n  MUTATION_COLOR_AMOUNT\n  MUTATION_PROBABILITY\n  CIRCLES_ADD_PROBABLITY\n  CIRCLES_DELETE_PROBABLITY\n\n  def map_rad(value):\n      # min max for radius\n      mapped_value = min + (value * max)\n      return mapped_value\n```\nThey can all be modified to get different outcomes.\n## Gallery\n![fuji](https://github.com/ZionC27/Computational-Art-with-Genetic-algorithm/assets/56661548/8df77624-816e-48e1-85e5-7beb0b83880b)\n![21800](https://github.com/ZionC27/Computational-Art-with-Genetic-algorithm/assets/56661548/a167c99a-2d5a-41b7-9800-391bd6164578)\n21800 Generations, 1000 Initial circles Population 200\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzionc27%2Fcomputational-art-with-genetic-algorithm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzionc27%2Fcomputational-art-with-genetic-algorithm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzionc27%2Fcomputational-art-with-genetic-algorithm/lists"}