/GA_For_ImageSegmentation

Genetic Algorithm For Image Segmentation.

Primary LanguagePython

Image Segmentation Using Genetic Algorithm

We can use genetic algorithm to determine k-1 thresholds to obtain k segments of an image.

The process of segmentation of an image is similar to segmentation using otsu and multi otsu thresholding. However to determine the thresholds we use genetic algorithm.

It is suitable for grayscale image only.

Algorithm goes something like this.

  • Define a initial population where a individual/state is k-1 thresholds for k segments.
  • Define a fitness function
    • Usually entropy function or variance function
    • Measures the fitness of a individual thresholds
  • Perform further steps of genetic algorithm using the above population and fitness function.
  • The GA gives out a fittest individual i.e k-1 thresholds that maximizes the fitness function.

How Genetic Algorithm was implemented

I used PyGAD to implement the Genetic Algorithm because it made easier to carry out this experiment.

To Work On

  • [ ] Improve fitness function

How to run

  • python main.py <img_path> <num_segments> <num_generation>

Results

  • They can be found on “./outputs”

Resources