All Projects → rh12503 → triangula

rh12503 / triangula

Licence: MIT license
Generate high-quality triangulated and polygonal art from images.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to triangula

Circle Evolution
Evolutionary Art Using Circles in Python
Stars: ✭ 237 (-93.72%)
Mutual labels:  art, genetic-algorithm, evolutionary-algorithms
Blossom
A lovely interactive music generator
Stars: ✭ 162 (-95.71%)
Mutual labels:  art, generative-art
incomplete-cubes-generator
Incomplete Open Cubes Generator
Stars: ✭ 18 (-99.52%)
Mutual labels:  art, generative-art
EvOLuTIoN
A simple simulation in Unity, which uses genetic algorithm to optimize forces applied to cubes
Stars: ✭ 44 (-98.83%)
Mutual labels:  genetic-algorithm, evolutionary-algorithms
Pxlsrt
Pixel sorter written in Ruby
Stars: ✭ 119 (-96.85%)
Mutual labels:  art, generative-art
Urpflanze
A library for developers who want to approach to creative coding, artists who want to approach coding and for those who find it fun to play with math.
Stars: ✭ 118 (-96.87%)
Mutual labels:  art, generative-art
datafsm
Machine Learning Finite State Machine Models from Data with Genetic Algorithms
Stars: ✭ 14 (-99.63%)
Mutual labels:  genetic-algorithm, evolutionary-algorithms
001
draw_code.001 — ThreeJS, WebGL & GLSL
Stars: ✭ 48 (-98.73%)
Mutual labels:  art, generative-art
machine-learning-blackjack-solution
Finding an optimal Blackjack strategy using AI
Stars: ✭ 40 (-98.94%)
Mutual labels:  genetic-algorithm, evolutionary-algorithms
JRubyArt
JRubyArt a ruby implementation of processing
Stars: ✭ 87 (-97.7%)
Mutual labels:  art, generative-art
stamps
A language for producing art
Stars: ✭ 116 (-96.93%)
Mutual labels:  art, generative-art
Generative.fm
A platform for playing generative music in the browser.
Stars: ✭ 1,534 (-59.36%)
Mutual labels:  art, generative-art
Geopattern
📐 Create beautiful generative image patterns from a string in golang.
Stars: ✭ 1,113 (-70.52%)
Mutual labels:  art, generative-art
Art Dcgan
Modified implementation of DCGAN focused on generative art. Includes pre-trained models for landscapes, nude-portraits, and others.
Stars: ✭ 1,882 (-50.15%)
Mutual labels:  art, generative-art
Emoji Art Generator
Use a genetic algorithm to evolve an image by putting emojies on a canvas
Stars: ✭ 53 (-98.6%)
Mutual labels:  art, genetic-algorithm
generative-art-Processing
Processingによるアート作品をまとめたリポジトリです.一部の作品はopenFrameworksで書かれています.This is a repository for art portfolio of Processing art. Some of arts are written in openFrameworks, one of the C++ libraries.
Stars: ✭ 31 (-99.18%)
Mutual labels:  art, generative-art
Awesome Creative Coding
Creative Coding: Generative Art, Data visualization, Interaction Design, Resources.
Stars: ✭ 8,696 (+130.36%)
Mutual labels:  art, generative-art
Sofloo Spot
Click Randomize
Stars: ✭ 37 (-99.02%)
Mutual labels:  art, generative-art
Generative-Art
A selection of generative art scripts written in Python
Stars: ✭ 284 (-92.48%)
Mutual labels:  art, generative-art
generative-art
I wanted to make a nicer sticker for Munihac, then things got out of hand.
Stars: ✭ 134 (-96.45%)
Mutual labels:  art, generative-art

An iterative algorithm to generate high quality triangulated and polygonal art from images.

Test status Go Reference Go Report Card License: MIT Tweet

Triangula uses a modified genetic algorithm to triangulate or polygonate images. It works best with images smaller than 3000px and with fewer than 3000 points, typically producing an optimal result within a couple of minutes. For a full explanation of the algorithm, see this page in the wiki.

You can try the algorithm out in your browser here, but the desktop app will typically be 20-50x faster.

Install

GUI

Install the GUI from the releases page. The GUI uses Wails for its frontend.

If the app isn't running on Linux, go to the Permissions tab in the executable's properties and tick `Allow executing file as program`.

CLI

Install the CLI by running:

go get -u github.com/RH12503/Triangula-CLI/triangula

Your PATH variable also needs to include your go/bin directory, which is ~/go/bin on macOS, $GOPATH/bin on Linux, and c:\Go\bin on Windows.

Then run it using the command:

triangula run -img <path to image> -out <path to output JSON>

and when you're happy with its fitness, render a SVG:

triangula render -in <path to outputted JSON> -img <path to image> -out <path to output SVG> 

For more detailed instructions, including rendering PNGs with effects see this page.

Options

For almost all cases, only changing the number of points and leaving all other options with their default values will generate an optimal result.

Name Flag Default Usage
Points --points, -p 300 The number of points to use in the triangulation
Mutations --mutations, --mut, -m 2 The number of mutations to make
Variation --variation, -v 0.3 The variation each mutation causes
Population --population, --pop, --size 400 The population size in the algorithm
Cutoff --cutoff, --cut 5 The cutoff value of the algorithm
Cache --cache, -c 22 The cache size as a power of 2
Block --block, -b 5 The size of the blocks used when rendering
Threads --threads, -t 0 The number of threads to use or 0 to use all cores
Repetitions --reps, -r 500 The number of generations before saving to the output file (CLI only)

Examples of output

Triangulated

Polygonal

Community Examples

Comparison to esimov/triangle

esimov/triangle seems to be a similar project to Triangula that is also written in Go. However, the two appear to generate very different styles. One big advantage of triangle is that it generates an image almost instantaneously, while Triangula needs to run many iterations.

esimov/triangle results were taken from their Github repo, and Triangula's results were generated over 1-2 minutes.

esimov/triangle Triangula

Difference from fogleman/primitive and gheshu/image_decompiler

A lot of people have commented about Triangula's similarities to these other algorithms. While all these algorithms are iterative algorithms, the main difference is that in the other algorithms triangles can overlap while Triangula generates a triangulation.

API

Simple example:

import imageData "github.com/RH12503/Triangula/image"

func main() {
    // Open and decode a PNG/JPEG
    file, err := os.Open("image.png")

    if err != nil {
          log.Fatal(err)
    }

    image, _, err := image.Decode(file)

    file.Close()

    if err != nil {
          log.Fatal(err)
    }

    img := imageData.ToData(image)


    pointFactory := func() normgeom.NormPointGroup {
          return (generator.RandomGenerator{}).Generate(200) // 200 points
    }

    evaluatorFactory := func(n int) evaluator.Evaluator {
          // 22 for the cache size and 5 for the block size
          // use PolygonsImageFunctions for polygons 
		  return evaluator.NewParallel(fitness.TrianglesImageFunctions(imgData, 5, n), 22)
    }

    var mutator mutation.Method

    // 1% mutation rate and 30% variation
    mutator = mutation.NewGaussianMethod(0.01, 0.3)

    // 400 population size and 5 cutoff
    algo := algorithm.NewModifiedGenetic(pointFactory, 400, 5, evaluatorFactory, mutator)

    // Run the algorithm
    for {
          algo.Step()
          fmt.Println(algo.Stats().BestFitness)
    }
}

Contribute

Any contributions are welcome. Currently help is needed with:

  • Support for exporting effects to SVGs.
  • Supporting more image types for the CLI and GUI. (eg. .tiff, .webp, .heic)
  • Allowing drag and drop of images from the web for the GUI.
  • More effects.
  • Any optimizations.

Thank you to these contributors for helping to improve Triangula:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].