Search code examples
optimizationcomputer-visionimage-compression

Image to N triangles with minimum loss of the color


Required to turn an image into N triangles with Delaunay triangulation. One color for each triangle, and colors can be repeated. The loss function is given by the square of the difference in the color of each pixel. So how to optimize the color and the vertices of triangles?


Solution

  • A recursive splitting procedure outline:

    Terminate the recursion if N < 2
    
    Split the given area A in two triangles A1 and A2 in such a way that the
    sum of standard deviations of the pixel colors is cut in halves. 
    Assign N/2 colors to A1 and N - N/2 colors to A2.
    
    Recursively split A1 and A2.
    

    The resulting net of N triangles is colored to minimize the loss function:

    For every triangle the color chosen is the average color of the pixels within that triangle.
    

    It might be worthwhile to conduct a survey of existing literature on the topic. A first search engine hit returned Fractal image compression based on Delaunay triangulation and vector quantization