
Show HN: Image-triangulation – Delaunay and Voronoi from scratch - EllipticCurve
https://github.com/MauriceGit/Delaunay_Triangulation
======
EllipticCurve
Hey guys,

it's my first post here, but I've been reading for a couple of months.

And right now I am ready to share some stuff I made. Please feel free to ask,
criticize or suggest alternatives :)

A couple of months ago someone here (don't have the link anymore) inspired me
to finally sit down and implement a delaunay-triangulation and voronoi from
scratch.

What the python-script (drawTriangles.py) does is:

\- take an image, extract points dependent on the contrast and color
difference of the image (more points on edges or in contrast-rich parts).

\- triangulate the points with a delaunay-triangulation (from scratch).

\- transform the delaunay-triangles into voronoi-regions.

\- render the triangles and voronoi-regions into new images with the average
color for each polygon (from the original image).

The delaunay-triangulation runs in Omega(n logn) but I'm not 100% sure if also
in O(n logn). The transformation into voronoi-regions runs in O(n).

Please tell me what you think :) Best regards Maurice

~~~
arketyp
Nice work. The triangulation is a nice structure to get to know. You might be
interested in something called data-dependent triangulation. The idea is that
non-conventional triangulations (i.e., not Delaunay) make for good
interpolating schemas, based on assumptions such as smoothness in the color
intensity profile and so on. I wrote a Master's thesis [1] about this among
other things such as decimating a dense triangulation mesh in strategic ways
(using edge detection).

[1] [http://uu.diva-
portal.org/smash/record.jsf?pid=diva2%3A85902...](http://uu.diva-
portal.org/smash/record.jsf?pid=diva2%3A859026&dswid=-6921)

[Edit: My old blog with plenty of pictures:
[https://femtondev.wordpress.com/](https://femtondev.wordpress.com/) ]

~~~
megalodon
That blog contains some impressive image processing with examples, thank you
for linking.

------
shaneos
Very cool!

In case C++ is your jam, ten years or so ago I adapted Steven Fortunes highly
efficient sweep line algorithm to C++.

Some info here -
[http://www.skynet.ie/~sos/mapviewer/voronoi.php](http://www.skynet.ie/~sos/mapviewer/voronoi.php)

A desktop app I built to use this code, generating Voronoi and Delaunay
graphs, along with way more robotics/navigation/map generation stuff called
MapViewer -
[http://www.skynet.ie/~sos/mapviewer/main.php](http://www.skynet.ie/~sos/mapviewer/main.php)

Code on Sourceforge (yes, 10 years ago people) -
[http://www.skynet.ie/~sos/mapviewer/voronoi.php](http://www.skynet.ie/~sos/mapviewer/voronoi.php)

~~~
EllipticCurve
Very nice!

No problem with C or C++ (I am mainly working in C for OpenGL stuff for
years).

I chose Python because I wanted to concentrate on the algorithm (didn't know,
if there were obstacles along the way...). So in Python I could just go for
executable pseudo-code :)

------
ingenter
Very cool!

Is it possible to modify the algorithm to use vertex color instead of triangle
color? It is possible to do interesting stuff like Homeworld 2 backgrounds.

[http://simonschreibt.de/gat/homeworld-2-backgrounds/](http://simonschreibt.de/gat/homeworld-2-backgrounds/)

~~~
EllipticCurve
You mean like interpolating the colors from each vertex?

Yes, it's possible and quite easy to do so :)

I make a list of things to do - Homeworld 2 is on it ;)

------
NarcolepticFrog
This is awesome! I worked on a very similar project a few months ago, which I
also posted to HN:
[https://news.ycombinator.com/item?id=10418829](https://news.ycombinator.com/item?id=10418829)

Looks like yours is quite a bit more polished :)

------
EllipticCurve
All right, I added some pictures to the README of the repository, so you don't
have to dig around to look at them :)

------
jheriko
well done, i guess...

