Genetic Seam Carving: A Genetic Algorithm Approach for Content-Aware Image Retargeting
Implementation of the genetic seam carving algorithm described in the references below. Genetic Seam Carving is an evolutionary algorithm for content-aware image resizing.
Python 3
pip install -r requirements.txt
usage: main.py [-h] [--energy {sobel,scharr}]
[--selection {roulette,tournament}]
[--crossover {onepoint,twopoint,uniform}]
[--mutation {uniform,shuffle,flipbit}] [--display]
input target_shape target_shape output pop_size num_gens mut_pb
Genetic Seam Carving
positional arguments:
input Input image
target_shape Target image shape in 'row col' format
output Output image
pop_size Population size
num_gens Number of generations
mut_pb Mutation probability
optional arguments:
-h, --help show this help message and exit
--energy {sobel,scharr}
Energy map gradient
--selection {roulette,tournament}
Selection operator
--crossover {onepoint,twopoint,uniform}
Crossover operator
--mutation {uniform,shuffle,flipbit}
Mutation operator
--display Display visualization
python3 main.py small_tower.jpg 242 286 smaller_tower.jpg 5 10 0.05
python3 main.py whale.jpg 340 408 whale_out.jpg 10 30 0.05 --crossover uniform