Search code examples
c#.netcolorsbitmaptriangulation

Create a triangle filled Bitmap based on the colors of the underlying image


What I'm trying to achieve

  1. A Bitmap that is filled with triangles.
  2. The triangles' separation depends on if the color change from one pixel to the next is too much.
  3. The color of each triangle depends on the median color value from the entire area of pixels inside of the triangle.

What I'm struggling with
Finding the best way to check for triangles under this condition.

What I've thought of but couldn't succeed

  1. Have a nested loop that checks for each pixel color by row and column of the bitmap, if it's a drastic change start going down, else go down-left, etc.
  2. Color every part on the Bitmap that has relatively the same color through Lists. Make triangles later.

Anything would be helpful, I can provide my current code if needed also a drastic color change is measured based on the tolerance variable

Edit
Picture before process
Picture after process
So I'd like to make a bitmap of an image (which I've done) and have the code color over that bitmap based on the conditions I layed out. The after process picture is basically what would happen if the tolerance variable is very high, but in general the triangles should be way smaller to perform finer color transitions. Thanks


Solution

  • The way I understand your goal is using the "drastic color change" technique -if you're able to define it correctly- to figure out edges of triangles.

    Then, with these edges and some isolated points you could do a constrained triangulation, usually a Constrained Delaunay Triangulation (CDT).

    Shewchuk has good papers about this CDT. And also a free program Triangle in C. Perhaps you find some "clone" in C# or .net