Skip to content

Zia-Ur-Rehman1/Evolutionary_Algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧬 Evolutionary Algorithm

Project Title: Evolutionary Algorithm for Template Matching using Natural Selection Principles


👨‍🔬 Project Overview

This project implements image template matching using evolutionary algorithms inspired by Darwin's Theory of Natural Selection. Instead of traditional pattern matching, the algorithm simulates evolution via selection, crossover, and mutation to find image segments that match a given template.


🧠 Team Members

  • 👨‍💻 Group Leader: Zia Ur Rehman
  • 🧑‍💻 Members: Noor Nabi, Shahrukh Khan

📖 Table of Contents


📖 Abstract

Instead of traditional programming techniques, this algorithm replicates Darwinian evolution by initializing a population and improving each generation based on fitness. The ultimate goal is to find a match between a template image and the best-fitting region in a larger image.


🌱 Natural Phenomenon

Darwin's theory revolves around survival of the fittest. Organisms evolve and adapt by selecting traits that maximize survival. This concept is used in this algorithm by generating, evaluating, and evolving image segments.

Evolution


📚 Charles Darwin's Theory

  • Species evolve through small, beneficial adaptations.
  • Favorable traits are preserved, unfavorable ones are eliminated.
  • Populations diverge over time into new species (macroevolution).

🔬 Evolution

  • Overpopulation and competition drive evolution.
  • Offspring with superior traits survive.
  • Speciation can be allopatric (geographic) or sympatric (genetic drift).

🧪 Model

  • Population of image slices is initialized.
  • Fitness is measured using correlation with the target template.
  • Top individuals survive and generate the next generation using crossover and mutation.

Model


💻 Application

🖼 Import Image

Images are converted into 2D grayscale matrices using Python (matplotlib).

✂️ Slicing

The large image is randomly sliced into smaller segments (same size as template) based on random coordinates.

⚙️ Initialization

Initial random population of image segments is generated. Fitness is calculated via Pearson correlation. NumPy is used for optimization.

🔢 Sorting

Fitness values are sorted in descending order to select top candidates.

🧬 Crossover and Mutation

  • Genetic operators applied to top individuals.
  • Mutation done on significant bits or coordinates.
  • Optimal parameters: 95% crossover, 0.5% mutation.

🛑 Termination

Process continues until a desired correlation threshold (e.g. 0.9) is reached.


🧪 Testing

  • With larger populations (e.g. 1000), convergence to high correlation is faster.
  • Randomization affects consistency of improvement.
  • Best results require tuning mutation/crossover logic.

Results Results Results Fix


✅ Conclusion

The algorithm demonstrates how biological logic can be adapted into computational models. While not always producing a steadily increasing fitness graph, evolutionary methods offer flexibility and resilience. Increasing initial population size significantly improves results.


🔗 References

  1. Live Science
  2. Khan Academy on Speciation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages