This project implements a genetic algorithm for image reconstruction. The goal is to evolve a population of random images to resemble a target image.
To run this project, you need to have the following libraries installed:
- NumPy
- Matplotlib
- PIL (Python Imaging Library)
- Clone the repository to your local machine.
- Place the target image you want to reconstruct in the same directory as the script.
- Open the script file
image_reconstruction.py. - Adjust the genetic algorithm parameters if needed:
population_size: The size of the population (default: 100).generations: The number of generations to evolve the population (default: 5000).mutation_rate: The probability of mutation for each individual (default: 0.5).
- In the
main()function, specify the path to the target image by updating theimage_pathparameter in theload_image()function call. - Save the script file.
- Run the script using a Python interpreter:
python image_reconstruction.py. - The script will generate the reconstructed image and save it as
reconstructed_image.jpgin the same directory. - The original and reconstructed images will be displayed side by side in a matplotlib window.
Here are some examples of reconstructed images using this algorithm:

