In this task, you have to approximate an image using a given number of transparent triangles.
Your input will be a JPG image and the number of triangles you can use.
Your output should consist of N lines (where N equals the number of triangles). The structure of lines is the following:
X1 Y1 X2 Y2 X3 Y3 R G BX1 Y1, X2 Y2, X3 Y3 are floating point numbers specifying the three vertices of the triangle. The X coordinate is mapped as follows: the left edge of the leftmost pixel is 0; the right edge of the rightmost pixel is 1. Similarly, the top edge of the topmost pixel has the Y coordinate 0, while the bottom edge to the bottommost pixel is 1. It is allowed to have vertices outside the image (in this case the triangle will be clipped by the canvas boundaries).
R G B are three integers, from 0 to 255, specifying the color of the triangle.
Starting with a gray (#808080) canvas, each triangle will be drawn using 50% alpha transparency, with sub-pixel accuracy. Your score will be determined by how close this ends up to the original image, compared to submissions from other teams.
Difference between two images is defined as the total sum of differences between pixel colors. For each corresponding pixel, the differences of the R G B channels are summed. The smaller the total sum, the better.
This problem is a scaled problem; your submissions are compared against each other.
Input image (example.jpg), triangle count 10, and its approximation:
0.871795 0.4125 0.564103 0.975 -0.269231 0.4 255 255 0 1.14103 0.325 1.30769 1.4375 0.24359 1.15 232 0 0 1.12821 0.6125 -0.192308 0.6 0.564103 0.1 255 255 0 1.03846 0.575 0.320513 0.8875 0.269231 -0.175 255 255 0 0.666667 0.5 0.692308 0.7875 0.346154 0.3625 0 0 0 -0.269231 -0.375 -0.217949 0.6875 0.730769 -0.15 237 0 0 0.0384615 0.4125 0.769231 -0.0125 0.487179 1.2125 255 255 0 0.602564 1.0375 -0.435897 0.0375 -0.025641 1.3 229 0 0 1.39744 0.8875 1.23077 0.175 -0.0641026 -0.425 231 0 0 0.923077 1.325 1.05128 1.05 0.0897436 -0.0125 141 0 0For this approximation, our calculated difference is 2708674.
The exact formula that determines your final score is:
finalscore = 100(5-value/min)/4
Where min is the score received by the best submission so far, and value is the score received by your submission.