Skip to content

GeneticTextures.jl is an interactive package for evolving textures using genetic programming techniques.

License

Notifications You must be signed in to change notification settings

jofrevalles/GeneticTextures.jl

Repository files navigation

GeneticTextures.jl

GeneticTextures.jl is a Julia package inspired by the paper Artificial Evolution for Computer Graphics by Karl Sims. It allows you to interactively evolve textures using genetic programming techniques, bringing the power of evolutionary algorithms to the world of computer graphics.

Example images

Installation

To install GeneticTextures.jl, open your Julia REPL and type the following commands:

using Pkg
Pkg.add("https://github.com/jofrevalles/GeneticTextures.jl.git")

Usage

using GeneticTextures

n = 6
width = 128
height = 128
max_depth = 3

mutation_probs = Dict(
    :rand_expr => 0.06,
    :adjust_scalar => 0.1,
    :adjust_color => 0.1,
    :rand_func => 0.08,
    :add_argument => 0.1,
    :become_argument => 0.08,
    :duplicate_node => 0.03,
)

# Create initial population
original_population, original_image = generate_population(1, primitives_with_arity, max_depth, width, height)
population, images = create_variations(1, original_population, mutation_probs, primitives_with_arity, max_depth, width, height)

# Display original and mutated images
display_images(original_image[1], images)

# Interactively evolve textures
let population = population, images = images
    while true
        best_choice = get_user_choice(n)
        chosen_image = images[best_choice]

        if best_choice === nothing
            break
        end

        population, images = create_variations(best_choice, population, mutation_probs, primitives_with_arity, max_depth, width, height)
        display_images(chosen_image, images)
    end
end
UI-example

Examples

Here are some examples of textures generated with GeneticTextures.jl:

Examples

Benchmarks

We also benchmarked the performance of the different function backends available in GeneticTextures.jl.

Benchmarks

Acknowledgments

GeneticTextures.jl makes use of the following third-party packages:

  • CoherentNoise (MIT License)
  • Colors (MIT License)
  • ForwardDiff (MIT License)
  • Images (MIT License)
  • Plots (MIT License)

About

GeneticTextures.jl is an interactive package for evolving textures using genetic programming techniques.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages