Git Product home page Git Product logo

delaunay_triangulation's Introduction

Delaunay Triangulation and Voronoi Regions in images

This project consists of several parts which are joined together.

Image of an end result: Voronoi-diagrams of a sunset

  • Triangulation

    I always wanted to properly implement a Delaunay triangulation. So here it is. It runs in Omega(n logn). As soon as I change the data structure, also in O(n logn). Anyway. You provide a list of points (tuples with x,y-coordinates!) and get back a list of triangles (also tuples with three points per triangle!). In the new version it also transforms the triangles into Voronoi regions (polygons --> list of list of points).

    Example image of 100 random points triangulated: Image of a triangulation of 100 points

  • Image-Triangulation:

    This is the actual application of the Delaunay triangulation. You can specify a .jpg-Image and the program will perform some gauss-filtering and edge detection. Based on the contrast difference of the image there is a propability that a point is set on that spot (per pixel). With that there will be more points generated in areas with high contrast differences than in areas with equal colors and contrasts. These points will then be triangulated. After that each triangle will get colored with the approximate mean color of the pixels inside the triangle. Approximate because only the Vertices and the center of the triangle will be considered. These colored triangles will then be rendered into an new jpg-image.

    Example image with about 4000 different points triangulated and colored according to the original picture: Image of a triangulation of a photo of a sunset

    Example image when the points are equally distributed and not extracted from the picture: Image of a triangulation of a photo of some fireworks

  • Voronoi-Diagrams:

    The Delaunay triangulation is taken and transformed in O(n) into Voronoi regions. These regions will then be rendered into an image just like the triangles before. The color is determined by the average color of each corner and the center of the polygon.

    Example image directly converted from triangles to Voronoi regions: Image of Voronoi regions

    Now with equally distributed point selection (looking a bit better with Voronoi regions in my opionion): Image of equally distributed Voronoi regions

  • Point-Distribution:

    There are different options for determining points in the image for triangulation. Points can be determined from edge-detection and are more common in parts of the image where bigger color-differences occure. Otherwise points can be distributed equally over the image space. The choice has a quite big influence on the outcome-image. For the Delaunay triangulation I prefer more points in edging areas. For Voronoi regions it looks more pleasant if the regions are more equally distributed. Anyway the results are stunning (in my opinion) :).

    Result of a triangulation with point-extraction from edges and constrast: Image with triangles from edges

    The next image shows the exact same extracted triangles with random colors and not colored from the photo: Triangles with random colors

delaunay_triangulation's People

Watchers

James Cloos avatar Mohan Liu 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.