Code Monkey home page Code Monkey logo

triangle's Introduction

โ–ฒ Triangle

Triangle is a tool to create image arts using the delaunay triangulation technique. It takes an image as input and it converts to abstract image composed of tiles of triangles.

Sample image

The technique

  • First the image is blured out to smothen the sharp pixel edges. The more blured an image is the more diffused the generated output will be.
  • Second the resulted image is converted to grayscale mode.
  • Then a sobel filter operator is applied on the grayscaled image to obtain the image edges. An optional threshold value is applied to filter out the representative pixels of the resulting image.
  • Lastly we apply the delaunay algorithm on the pixels obtained from the previous step.
blur = tri.Stackblur(img, uint32(width), uint32(height), uint32(*blurRadius))
gray = tri.Grayscale(blur)
sobel = tri.SobelFilter(gray, float64(*sobelThreshold))
points = tri.GetEdgePoints(sobel, *pointsThreshold, *maxPoints)

triangles = delaunay.Init(width, height).Insert(points).GetTriangles()

Installation and usage

$ go get github.com/esimov/triangle/cmd/triangle
$ go install

Supported commands

$ triangle --help

The following flags are supported:

Flag Default Description
in n/a Input file
out n/a Output file
blur 4 Blur radius
max 2500 Maximum number of points
noise 0 Noise factor
points 20 Points threshold
sobel 10 Sobel filter threshold
solid false Solid line color
wireframe 0 Wireframe mode (without,with,both)
width 1 Wireframe line width

Setting a lower points value, the resulted image will be more like a cubic painting. You can even add a noise factor, giving a more artistic, despeckle like result for the final image.

Here are some examples you can experiment with:

$ triangle -in samples/clown_4.jpg -out output.png -wireframe=0 -max=3500 -width=2 -blur=2
$ triangle -in samples/clown_4.jpg -out output.png -wireframe=2 -max=5500 -width=1 -blur=10

Below are some of the generated images:

Sample_0 Sample_1 Sample_11 Sample_8

License

This project is under the MIT License. See the LICENSE file for the full license text.

triangle's People

Contributors

esimov avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.