Author: Daivik Girish
UCID: dg643
- Challenge: Design camouflaging patterns that blend an object into its background.
- Objective: Reduce detectability by humans and machine vision by maximizing visual and structural similarity and minimizing saliency.
- Military & Security: Conceal equipment and personnel.
- Computer Vision: Test robustness of recognition algorithms.
- Biomimicry: Inspire design from nature's camouflage.
- Human-Computer Interaction: Enhance AR and interface visuals.
- Initialization: Load object/background images, generate random camouflage patterns.
- Fitness Evaluation: Blend object and background, calculate MSE, SSIM, and saliency.
- Selection: Elite selection of best individuals.
- Crossover & Mutation: Create new patterns via blending crossover and Gaussian mutation.
- Repetition: Iterate for a set number of generations, tracking fitness and image quality.
object_image_path: Path to object imagebackground_image_path: Path to background imageimage_size: Resize images (e.g., 64x64)num_generations: Number of generationspopulation_size: Number of chromosomes (e.g., 50)mutation_rate: Probability of mutation per genemutation_strength: Std. dev. for Gaussian noisenoise_strength: Random noise intensity during mutation
- MSE: Mean squared error between blended and background images
- Saliency Map: Highlights visually important regions
- SSIM: Structural similarity index
- Final Fitness:
SSIM - MSE - Saliency
- Blending Crossover:
offspring1 = α * parent1 + (1-α) * parent2offspring2 = α * parent2 + (1-α) * parent1αrandomly chosen in [0.4, 0.6]
- Gaussian Mutation:
- Applies noise to randomly selected genes
- Values clamped to [0, 1] (valid pixel range)
- Fitness vs. Generations: Shows improvement over time
- Final Blended Image: Demonstrates effective camouflage after 3000 generations
- Language: Python
- Libraries:
torch(with GPU support)numpy,matplotlib,scikit-image,torchmetrics
- Hardware: CPU/GPU compatible
- Genetic Algorithm evolves effective camouflage patterns
- Combined fitness (SSIM, MSE, saliency) ensures both visual and structural similarity
- Final patterns significantly reduce object saliency
- Is GA the best for image camouflaging?
- Not always; alternatives like neural networks or other evolutionary strategies may outperform GA in some cases.
- Future Directions:
- Hybrid GA + Deep Learning (e.g., CNNs)
- Real-time processing
- Refined mutation/crossover strategies
├── main.py # Main entry point
├── camouflage_ga.py # Genetic algorithm class
├── config.py # Configuration and hyperparameters
├── image_utils.py # Image processing utilities
├── fitness_functions.py # Fitness evaluation functions
├── genetic_operators.py # Crossover and mutation operators
├── visualization.py # Plotting and visualization functions
├── requirements.txt # Python dependencies
├── images/ # Input images (object/background)
├── presentation/ # Project presentation (PPTX, docs)
└── README.md # This file
- Place your object and background images in the
images/folder asimage.jpgandbackground.jpg. - Install dependencies:
pip install -r requirements.txt
- Run the main script:
python main.py
- Missing images: Ensure
images/image.jpgandimages/background.jpgexist or update paths inconfig.py. - Import errors: Install all dependencies from
requirements.txt. - CUDA out of memory: Reduce image size or population size, or run on CPU.
- Slow performance: Use GPU if available, or reduce generations/population size.
Contributions are welcome! To contribute:
- Fork the repository
- Create a new branch for your feature or bugfix
- Make your changes with clear commit messages
- Submit a pull request with a description of your changes
For more details, see the presentation in the presentation/ folder.