Skip to content

EngSteven/genetic-image-vectorization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image Vectorization with Genetic Algorithms

Overview

This project is an academic work for the Algorithm Analysis course at Tecnológico de Costa Rica, Centro Académico de Limón.
Developed by Steven Sequeira and Josue Echeverria.

The goal of the project is to vectorize a black and white (1-bit) image by implementing a genetic algorithm. The algorithm gradually evolves a population of candidate solutions — each represented as a list of coordinates (x, y) — to reproduce the input image as a linear drawing.

Inspired by the theory of evolution, the algorithm selects and improves individuals across generations based on a fitness function designed by our team. The only access to the image data is through this fitness function, which measures how closely each individual matches the target image.

Features

  • Allows the user to configure key genetic algorithm parameters:
    • Target image
    • Maximum number of generations
    • Population size per generation
    • Percentage of individuals selected for reproduction
    • Percentage of individuals allowed to mutate
    • Percentage of individuals allowed to combine
  • Validates that the last three percentages sum to 100%, warning the user if not.
  • Interactive UI elements (e.g., sliders) for intuitive parameter adjustment.
  • Real-time visualization of the evolution process, including:
    • A timer showing total elapsed time and average time per generation.
    • A line chart displaying both the average fitness and best fitness over generations.

Implementation

  • Fully developed in JavaScript.
  • Uses libraries like OpenCV.js to apply raster filters if needed (vectorization must be implemented by the genetic algorithm itself).
  • The genetic algorithm operates strictly through the fitness function; direct pixel manipulation for vectorization is not allowed.
  • All code is documented and structured for clarity.

How to Run

  1. Open the index.html file in your browser.
  2. Upload a black and white image (1-bit) as the target.
  3. Adjust genetic algorithm parameters using the interface.
  4. Start the algorithm and observe:
    • The convergence process through fitness graphs.
    • Real-time timer statistics.

Note: Proper convergence depends on the chosen parameters and the complexity of the input image.

Authors

  • Steven Sequeira
  • Josue Echeverria

License

This project is intended for academic purposes.
All algorithms and code are original implementations by the authors.

About

Genetic algorithm that vectorizes black and white images into line drawings

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published