Skip to content

Create images from triangles using a genetic algorithm.

License

Notifications You must be signed in to change notification settings

kkestell/tri-klops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tri-Klops

Create images from triangles using a genetic algorithm.

Tri-Klops

Usage

Tri-Klops

Usage: triklops.exe [OPTIONS] <REFERENCE_IMAGE_PATH>

Arguments:
  <REFERENCE_IMAGE_PATH>  Path to the reference image

Options:
  -o, --output <OUTPUT_PATH>
          Output path (optional)
  -t, --num-triangles <NUM_TRIANGLES>
          Number of triangles [default: 512]
  -a, --algorithm <ALGORITHM>
          Fitness evaluation algorithm [default: mse] [possible values: ssim, mse]
  -i, --image-size <IMAGE_SIZE>
          Image size (width and height) [default: 256]
  -g, --num-generations <NUM_GENERATIONS>
          Number of generations [default: 512]
  -p, --population-size <POPULATION_SIZE>
          Population size [default: 256]
  -s, --num-selected <NUM_SELECTED>
          Number of individuals selected per generation [default: 128]
  -m, --mutation-rate <MUTATION_RATE>
          Mutation rate [default: 0.1]
  -d, --degeneracy-threshold <DEGENERACY_THRESHOLD>
          Degeneracy threshold (optional)
  -f, --save-frequency <SAVE_FREQUENCY>
          Save frequency [default: 1]
  -r, --seed <SEED>
          Seed for the random number generator (optional)
  -h, --help
          Print help

Examples

Basic usage with default settings:

cargo run --release -- path/to/reference_image.jpg

Custom configuration:

cargo run --release -- path/to/reference_image.jpg \
  --image-size 512 \
  --num-triangles 1000 \
  --num-generations 1000 \
  --population-size 512 \
  --num-selected 256 \
  --mutation-rate 0.05 \
  --algorithm ssim \
  --degeneracy-threshold 10.0 \
  --save-frequency 20

More Examples

Reference Image Output Image
Reference Image Output Image
cargo run --release -- examples/tri-klops.jpg \
    --image-size 256 \
    --num-triangles 256 \
    --num-generations 256 \
    --population-size 256 \
    --num-selected 128 \
    --mutation-rate 0.10 \
    --algorithm mse
Reference Image Output Image
Reference Image Output Image
cargo run --release -- examples/zardoz.jpg \
    --image-size 512 \
    --num-triangles 512 \
    --num-generations 512 \
    --population-size 128 \
    --num-selected 64 \
    --mutation-rate 0.10 \
    --algorithm ssim
Reference Image Output Image
Reference Image Output Image
cargo run --release -- examples/castle.jpg \
    --image-size 256 \
    --num-triangles 512 \
    --num-generations 512 \
    --population-size 512 \
    --num-selected 256 \
    --mutation-rate 0.10 \
    --algorithm mse
Reference Image Output Image
Reference Image Output Image
cargo run --release -- examples/kanagawa.jpg \
    --image-size 128 \
    --num-triangles 512 \
    --num-generations 512 \
    --population-size 128 \
    --num-selected 64 \
    --mutation-rate 0.10 \
    --algorithm ssim