An iterative algorithm to generate high-quality triangulated images.

Overview

An iterative algorithm to generate high quality triangulated images.

Test status Go Reference Go Report Card License: MIT Tweet

Introduction

Triangula uses a modified genetic algorithm to triangulate 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.

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

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

API

Simple example:

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
            return evaluator.NewParallel(img, 22, 5, n)
      }

      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.NewSimple(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:

  • 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.
Issues
  • Stop button does not work if

    Stop button does not work if "Time per Frame" is set too low

    If you set "Time per Frame" to 10 or 25 and start with triangulation you are not able to stop it with the "Stop" button, because it does not react. When "Time per Frame" is set to 250 the "Stop" button works as intended.

    opened by gocursor 13
  • Ken Thompson Image

    Ken Thompson Image

    Hi maintainers, the image of Ken Thompson that you are using cannot be included in this project under an MIT license as the underlying image is licensed under CC-BY-NC-SA. Please note that in your license docs along with proper attribution or remove it. Thanks.

    opened by padams 7
  • How do I build from source?

    How do I build from source?

    Hi, I cloned this repo and ran go build and got this error:

    no Go files in C:\Users\milo5\Desktop\GitHub\triangula
    

    Any ideas on how I can build from source?

    My antivirus doesn't let me download the gui so I'm trying to self build it. Thanks!

    opened by Milo123459 4
  • Left Side of Image Appears to Have Slight Triangulation Bias

    Left Side of Image Appears to Have Slight Triangulation Bias

    This project is amazing. Thank you for building and uploading it. The outputs are remarkable and it makes computers seem like magic to me again.

    It appears Triangula is somewhat biased to render / use triangle budget on the left side of images. Parts of an image further to the left seem to resolve to better detail. Not sure if it works better to allow images to process far longer, but it seems to stop making a difference after a while.

    I don't know if this is either known, an actual issue, or helpful to you. Again, thanks for building something so cool and even... inspiring.

    Target Photo: https://en.wikipedia.org/wiki/USS_America_(CV-66)#/media/File:USS_America_(CV-66)_underway_in_the_Indian_Ocean_on_24_April_1983.jpg Dimensions: 2586 x 1769 Size: 2.11 MB Filetype: .PNG (I converted it PNG before using)

    Default Settings, 1,000 Points image

    Default Settings, 2,000 Points image

    Target Photo: https://en.wikipedia.org/wiki/Mount_Rushmore#/media/File:Mount_Rushmore_detail_view_(100MP).jpg Dimensions: 1588 x 1080 Size: 655 KB Filetype: .jpg

    Default Settings, 1,000 Points image

    Default Settings, 2,000 Points See the figure's detail on the far left (George Washington) vs the figure on the far right (Abraham Lincoln) image

    opened by plynml-c 4
  • White screen when launching GUI

    White screen when launching GUI

    I have a white screen on startup

    Screenshot_20210426_164439 Triangula version: 1.1.2 OS: Manjaro (KDE Plasma) Stdout:

    (Triangula:45221): Gtk-WARNING **: 16:44:14.988: Theme parsing error: gtk.css:73:46: The style property GtkScrolledWindow:scrollbars-within-bevel is deprecated and shouldn't be used anymore. It will be removed in a future version
    Overriding existing handler for signal 10. Set JSC_SIGNAL_FOR_GC if you want WebKit to use a different signal
    Control
    
    (WebKitWebProcess:45235): Gtk-WARNING **: 16:44:15.065: Theme parsing error: gtk.css:73:46: The style property GtkScrolledWindow:scrollbars-within-bevel is deprecated and shouldn't be used anymore. It will be removed in a future version
    
    (WebKitWebProcess:45235): Gtk-WARNING **: 16:44:15.097: Theme parsing error: gtk.css:68:35: The style property GtkButton:child-displacement-x is deprecated and shouldn't be used anymore. It will be removed in a future version
    
    (WebKitWebProcess:45235): Gtk-WARNING **: 16:44:15.097: Theme parsing error: gtk.css:69:35: The style property GtkButton:child-displacement-y is deprecated and shouldn't be used anymore. It will be removed in a future version
    
    (WebKitWebProcess:45235): Gtk-WARNING **: 16:44:15.097: Theme parsing error: gtk.css:71:36: The style property GtkCheckMenuItem:indicator-size is deprecated and shouldn't be used anymore. It will be removed in a future version
    
    (WebKitWebProcess:45235): Gtk-WARNING **: 16:44:15.097: Theme parsing error: gtk.css:73:46: The style property GtkScrolledWindow:scrollbars-within-bevel is deprecated and shouldn't be used anymore. It will be removed in a future version
    
    (WebKitWebProcess:45235): Gtk-WARNING **: 16:44:15.097: Theme parsing error: gtk.css:76:30: The style property GtkExpander:expander-size is deprecated and shouldn't be used anymore. It will be removed in a future version
    

    How to fix this?

    opened by vadimalekseev 3
  • --reps CLI option does not work

    --reps CLI option does not work

    Using the CLI version, it appears that the -r and --reps options are ignored, as well as the claimed default of 500 reps, since no matter whether I supply the options or not, the algorithm still proceeds beyond the supplied number and continues until killed with CTRL+C.

    opened by geekoftheweek 2
  • [Improvement] Add community section to Readme

    [Improvement] Add community section to Readme

    Hey Ryan,

    here's a proposal for a little community section within the readme to link to projects based on Triangula.

    Feel free to adapt the styling or to add other projects you're aware of, I started off with my own little Insta channel.

    Cheers, Fabio

    opened by FabioMai 1
  • GUI not working: blank window

    GUI not working: blank window

    Hi, i downloaded the newest release (1.1.2) from the releasepage, ran chmod +x on the unzipped file and started the application.

    A window titled "Triangula" pops up, but it's completely blank:

    image

    Console reads:

    ╰─$ ./Triangula
    Overriding existing handler for signal 10. Set JSC_SIGNAL_FOR_GC if you want WebKit to use a different signal
    Control
    

    Enviroment:

    • Linux P1 5.11.15-200.fc33.x86_64 #1 SMP Fri Apr 16 13:41:20 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
    • Fedora 33 with Mate Desktop
    • nvidia binary drivers
    • NVIDIA Quadro T1000
    opened by phxql 1
  • CLI and file extensions

    CLI and file extensions

    I am doing this:

    IN=schach.jpg
    JSON=fitness
    SVG=schach
    
    triangula run -img "${IN}" -out "${JSON}"
    triangula render -in "${JSON}.json" -img "${IN}" -out "${SVG}"
    

    It is a bit weird to me that "-out" on run is adding a .json file extension even if I put in "fitness.json" already. A fallback for adding the extension is nice, but imho it should check if it is supplied already (strings.HasSuffix). That way I could use $JSON for both commands in the above example.

    opened by jojomi 1
  • Tiny controls on 4K display (Windows 10)

    Tiny controls on 4K display (Windows 10)

    Many thanks for the great project!

    However on 4K displays on Windows 10 I get veeery tiny controls ;) 2021-11-30 19_48_45-

    Size of controls doesn't change when resizing the window.

    opened by mschulze46 2
  • Allow capital file suffixes like .JPG in the file loading window

    Allow capital file suffixes like .JPG in the file loading window

    Hi, i love your programm but I have a small suggestion for improvment :-) When I want to load a new image using the GUI I can't select image files if the file suffix is in capital letters like image.JPG . I have to manually rename the file to image.jpg first. Maybe this can be fixed so that files ending with .JPG, .JPEG and .PNG can be selected too. Some Cameras and Smartphones save their images using suffixes like .JPG for some reason. Best regards, Marco

    opened by marcomuc 1
  • GUI unstoppable

    GUI unstoppable

    When I make a run within the GUI MOST of the times the application is unstoppable.

    • The stop button won't stop the run
    • The X in the window won't close
    • Even CTRL c in terminal won't halt the app
    • Only kill -9 will Fedora 35, tested on two different computers. Version 1.2.0
    opened by imp1sh 2
  • [Feature Request] Add settings about 'max generations' to automatically pause or stop.

    [Feature Request] Add settings about 'max generations' to automatically pause or stop.

    On my weak machine, the GUI application uses a lot of resources, works out of control and unstoppable. Even I can't save the generated result.

    Would you like to add a settings about "max generation in one turn" to limit generating in one click on "Start"? If the generation match max value, it will automatically pause and waits for next "Start".

    opened by zombie110year 3
  • Works great! Suggestion about referencing each other's projects

    Works great! Suggestion about referencing each other's projects

    Hi there,

    I saw your project mentioned on the Golang sub on Reddit. I knew about Wails already, but it never occurred to me that it produces such small and efficient binaries (when compared to Electron apps). I downloaded and played with your app. Great work!

    The reason I am writing this issue is because I have recently written and self-published a book about generative art in Go (https://preslav.me/generative-art-in-golang/). I thought it would be a great idea if we refer to each other's projects. There is a section in my book that I am planning to expand upon, where I refer to other nice Go projects from the same domain. I suppose, I can put yours there in a future update. You could do the same, either as part of the README or in the Wiki.

    How does that sound? Feel free to close the issue once you've read it.

    Cheers, Preslav

    opened by preslavrachev 1
Releases(v1.2.0)
Golang Genetic Algorithm

goga Golang implementation of a genetic algorithm. See ./examples for info on how to use the library. Overview Goga is a genetic algorithm solution wr

null 164 Jul 27, 2022
A native Go clean room implementation of the Porter Stemming algorithm.

Go Porter Stemmer A native Go clean room implementation of the Porter Stemming Algorithm. This algorithm is of interest to people doing Machine Learni

Charles Iliya Krempeaux 179 Oct 15, 2021
Golang implementation of the Paice/Husk Stemming Algorithm

##Golang Implementation of the Paice/Husk stemming algorithm This project was created for the QUT course INB344. Details on the algorithm can be found

Aaron Groves 28 Jan 23, 2022
Fast (linear time) implementation of the Gaussian Blur algorithm in Go.

Song2 Fast (linear time) implementation of the Gaussian Blur algorithm in Go.

Masaya Watanabe 49 Apr 24, 2022
k-means clustering algorithm implementation written in Go

kmeans k-means clustering algorithm implementation written in Go What It Does k-means clustering partitions a multi-dimensional data set into k cluste

Christian Muehlhaeuser 404 Aug 3, 2022
a* pathfinding algorithm written in go

astar a* (a-star) pathfinding algorithm written in go Wikipedia: EN: A* search algorithm DE: A*-Algorithmus Install go get github.com/jpierer/[email protected]

Julian Pierer 26 Mar 21, 2022
A tool for building identical machine images for multiple platforms from a single source configuration

Packer Packer is a tool for building identical machine images for multiple platforms from a single source configuration. Packer is lightweight, runs o

null 2 Oct 3, 2021
A High-level Machine Learning Library for Go

Overview Goro is a high-level machine learning library for Go built on Gorgonia. It aims to have the same feel as Keras. Usage import ( . "github.

AUNUM 343 Aug 6, 2022
A high performance go implementation of Wappalyzer Technology Detection Library

wappalyzergo A high performance port of the Wappalyzer Technology Detection Library to Go. Inspired by https://github.com/rverton/webanalyze. Features

ProjectDiscovery 294 Aug 5, 2022
A high-performance timeline tracing library for Golang, used by TiDB

Minitrace-Go A high-performance, ergonomic timeline tracing library for Golang. Basic Usage package main import ( "context" "fmt" "strcon

TiKV Project 43 May 5, 2022
An iterative algorithm to generate high quality triangulated images.

Triangula uses a modified genetic algorithm to triangulate 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.

null 3.7k Jul 29, 2022
Generate high-quality triangulated art from images.

An iterative algorithm to generate high quality triangulated images.

null 53 May 26, 2021
Eunomia is a distributed application framework that support Gossip protocol, QuorumNWR algorithm, PBFT algorithm, PoW algorithm, and ZAB protocol and so on.

Introduction Eunomia is a distributed application framework that facilitates developers to quickly develop distributed applications and supports distr

Cong 2 Sep 28, 2021
High quality cloud service emulators for local development stacks

emulators High quality Google Cloud service emulators for local development stacks Why? At FullStory, our entire product and backend software stack ru

Engineering at FullStory 81 Aug 3, 2022
Easy to use open source hardware to drive WS2811 LEDs with high-quality color

STOP DOING FADECANDY LEDs were not supposed to be given data pins YEARS of "temporal dithering" but no real-world use found for having more than three

Micah Elizabeth Scott 1.2k Jul 27, 2022
Generate, encode, and decode UUIDs v1 with fast or cryptographic-quality random node identifier.

A Go package for generating and manipulating UUIDs Generate, encode, and decode UUIDs v1, as defined in RFC 4122, in Go. Project Status v1.1.0 Stable:

AGExt 14 Jan 24, 2022
A Golang tool that does static analysis, unit testing, code review and generate code quality report.

goreporter A Golang tool that does static analysis, unit testing, code review and generate code quality report. This is a tool that concurrently runs

360 Enterprise Security Group, Endpoint Security, inc. 3k Jul 29, 2022
the pluto is a gateway new time, high performance, high stable, high availability, easy to use

pluto the pluto is a gateway new time, high performance, high stable, high availability, easy to use Acknowledgments thanks nbio for providing low lev

mobus 2 Sep 19, 2021
Go-enum-algorithm - Implement an enumeration algorithm in GO

go-enum-algorithm implement an enumeration algorithm in GO run the code go run m

Leon 1 Feb 15, 2022
Optimus is an easy-to-use, reliable, and performant workflow orchestrator for data transformation, data modeling, pipelines, and data quality management.

Optimus Optimus is an easy-to-use, reliable, and performant workflow orchestrator for data transformation, data modeling, pipelines, and data quality

Open Data Platform 632 Jul 29, 2022
Harness Drone/CIE SonarQube Plugin with Quality Gateway

Harness Drone/CIE SonarQube Plugin with Quality Gateway The plugin of Harness Drone/CIE to integrate with SonarQube (previously called Sonar), which i

null 1 Dec 14, 2021
dropspy is a (POC-quality) reworking of the C-language dropwatch tool in Go, with some extra features.

dropspy is a (POC-quality) reworking of the C-language dropwatch tool in Go, with some extra features.

fly.io 27 Mar 20, 2022
Quality of life tool for diablo2r. Automatically counts up and writes the game name into clipboard.

counterbaal Quality of life tool for people hosting diablo2 baalruns. Automatically counts up and writes the game name into clipboard. Probably only u

null 1 Jan 1, 2022
RISC-V meta assembler that adds quality of life features to assembly

Lox language TODOs (Partially complete) unreachable code. if a "return" has been found in a local scope and we encounter other code directly following

William Cleveland 0 Jan 11, 2022
Work with remote images registries - retrieving information, images, signing content

skopeo skopeo is a command line utility that performs various operations on container images and image repositories. skopeo does not require the user

Containers 5k Aug 8, 2022
An image server which automatically optimize non webp and avif images to webp and avif images

go-imageserver go-imageserver is an image server which automatically optimize no

DeltaLaboratory 4 Apr 18, 2022
Resize upladed images to s3 bucket with given sizes, and uploades new images back to bucket

Features Resize upladed images to s3 bucket with given sizes, and uploades new images back to bucket Environment Variables IMAGE_SIZES - formax 200x20

null 1 Feb 2, 2022
A PDF document generator with high level support for text, drawing and images

GoFPDF document generator Package gofpdf implements a PDF document generator with high level support for text, drawing and images. Features UTF-8 supp

Kurt Jung 4k Aug 3, 2022
A PDF document generator with high level support for text, drawing and images

GoFPDF document generator Package go-pdf/fpdf implements a PDF document generator with high level support for text, drawing and images. Features UTF-8

null 145 Jul 27, 2022