Skip to content

ApaarRaina/Edge-detection-using-Improved-Sobel-and-Genteic-Algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Edge Detection using Genetic Algorithm

This project implements an edge detection algorithm based on a Genetic Algorithm (GA) optimization strategy, inspired by the IEEE research paper: "Edge Detection Technique Using Genetic Algorithm Based Optimization" 🔗 Read the paper on IEEE Xplore

Overview

Traditional edge detection methods like Sobel, Canny, and Prewitt apply fixed kernels and thresholds. This project introduces an evolutionary approach, where a population of candidate thresholds evolves over generations using:

  • Fitness Evaluation
  • Crossover
  • Mutation
  • Selection

The optimal threshold learned through this process is then applied to highlight the edges in an image.

How to Run

  1. Clone the repository.

  2. Place the image (10081.jpg) in the project directory or change the image filename in main.py.

  3. Run the program:

    python main.py

File Structure

  • main.py – Main execution script that loads the image, computes gradients using Sobel kernels, and evolves threshold values via a Genetic Algorithm.

  • functions.py – Contains helper functions:

    • fitness
    • mating
    • crossover
    • mutation
  • 10081.jpg – Sample image used for edge detection.

  • README.md – Project documentation.

Dependencies

  • numpy
  • opencv-python
  • torch
  • matplotlib

Install all requirements using:

pip install -r requirements.txt

Result

The script displays a side-by-side comparison of:

  • The edge map obtained using the learned threshold.
  • The original grayscale image.

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages