Skip to content

A tool to create pretty triangular mesh representations of images.

Notifications You must be signed in to change notification settings

pazifical/adaptive-triangulizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AdapTri - Adaptive Triangulizer

Build Status codecov GitHub release

AdapTri is a command line tool to convert images to pretty triangularized versions of themselves. It is written in Rust 🦀 and can be either easily compiled 🔧 or downloaded as a release binary 📩.

Using mesh generation techniques from the scientific field of computational fluid dynamics 🌊, the underlying details of the input image can be preserved and result in a high quality triangular representation 🖼️.

🤔 Yet another image triangulizer?

You may have seen an image like the second one, right? There are many open and closed source solutions to convert a regular image to one that consists of single colored triangles. Some of them create pretty ones, some of them not. But you might have not seen one where the triangle size adapts to the underlying structure 🏗️ of the input image. This is achieved by an iterative mesh refinement strategy 🕷️.

🕸️ What is a Mesh?

A Mesh consists of vertices, edges and faces. In the case of a triangular Mesh, each face is a triangle.

Wait... what? That sounds rather complicated... but it actually is not that technical: Just imagine connecting a bunch of dots to triangles and you have a triangular mesh 👍. The goal is that those triangles are rather equilateral.

The most widely used technique to create a Mesh is the Delaunay Triangulation. Given a set of points (=vertices) and optionally segments, a triangular Mesh is constructed. It generates quality Meshes by adhering to a rule that enforces a maximization of each triangle's angles. For more information on the topic, please just read the Wikipedia article 📖.

♻️ How does the iterative refinement work?

After the initial triangulation of the image, each triangle's centroid 🎯 is closer inspected: The interpolated color is compared to the color of the underlying original image. If the difference is greater than a given threshold, a new vertex with the underlying color will be inserted at that position. After all triangles are inspected, the new set of vertices is triangulated again 🕸️.

📝 What's left to do:

  • Implement command line parsing
  • Improve input error handling



🔉 How to compile and/or run the program

If you have Rust (and Cargo) installed, the easiest way is to run the following code in the top directory:

cargo build --release

This will result in the compilation of the program. After it's finished, an executable will be created in the /target/release directory.

To see the possible command line arguments, just type

adaptri --help