evolutionary-image-vectorization
evolutionary-image-vectorization copied to clipboard
An algorithm for vectorizing raster images based on genetic algorithms and swarm intelligence.
Evolutionary Image Vectorization
An evolutionary approach to image vectorization, based on Genetic Algorithms (GA) and Particle Swarm Optimization (PSO). Check the report for more details on the implementation.
Genetic Algorithm
A set of colored and transparent polygons are evolved using a genetic algorithm to reproduce the target image as close as possible. Different improvements are implemented to increase converge speed and final result quality.
Particle Swarm Optimization
A set of segments are evolved to reproduce the most relevant contours of the target image. This approach is similar to an edge detection algorithm, with the advantage that the final contours returned are in a vectorized format.
Video vectorization
Both algorithms can be also used to vectorize videos:
Get started
- Clone the repository.
- Install the required dependencies by running
pip install -r requirements.txt. - Run
main.py [target] [algorithm]:target: the target image file name. Check thesamplesfolder for a list of available images. Supports also.gifsand.mp4files.algorithm: the algorithm to use, can be eitherGAorPSO.
In main.py it is possible to change the hyper-parameters used by each algorithm.
Project structure
- Folder
classescontains the implementation of the algorithms, for both GA and PSO. - Folder
samplescontains a set of sample images that can be used to test the models. main.pyis the main script that can be used to generate the vectorized image for one sample.benchmark.pycan be used to run multiple hyper-parameter combinations and report the results.