Image Archiver
Ivan has just been appointed as the CEO of Rezipit (a sub-company of a very successful startup). The company aims to develop an image archiver with the best compression efficiency and highest quality in the world. From his university studies, Ivan recalls that the smaller the number of distinct values in the file, the better it can be compressed. And the genius idea strikes his mind!
At the first stage of product development, he wants to design an algorithm that takes an image in an 8-bit RGB color model and produces an image of the same size with at most same-colored 4-side connected components so that the MSE (mean squared error) difference between the original and the output image will be as small as possible.
Since this is just a raw idea, Ivan asks you to develop the prototype.
Input Data
You are given tests: 01-k.png
, 02-k.png
, , 20-k.png
, where k
in each filename is replaced with value of .
Download inputs (problem-i-inputs.zip
)
Each PNG image is provided in an 8-bit RGB color model. In this model, each pixel color is represented by three integers .
Here is a short description of these tests:
Test | Image Size | |
---|---|---|
01-128.png |
||
02-3.png |
||
03-2.png |
||
04-5.png |
||
05-10.png |
||
06-32.png |
||
07-512.png |
||
08-512.png |
||
09-12.png |
||
10-8.png |
||
11-3.png |
||
12-16.png |
||
13-7.png |
||
14-64.png |
||
15-64.png |
||
16-32.png |
||
17-16.png |
||
18-128.png |
||
19-256.png |
||
20-1024.png |
Output Data
Submit images 01.png
, 02.png
, …, 20.png
with answers to the corresponding inputs. Some of the files may be missing.
We say that two pixels are connected if their cells share an edge and they have the same colors (tuples ).
An output image should:
- be in an 8-bit RGB color model (without opacity),
- have the same size as the input one,
- should contain at most connected components.
Scoring
Suppose a given image has dimensions .
For two images and of size , let us define their similarity score:
Let us consider one test and suppose that:
- is the input image.
- is your answer image and .
- is the baseline image for this test. The baseline image has all pixels of the same color selected optimally (the image has exactly one connected component). We set as .
Your final score for the test is calculated as follows:
- If the image provided is not properly formatted or the number of same-colored 4-side connected components is bigger than , your output gets .
- If , your output gets .
- Otherwise, your output will get a score that depends on the lowest number of points all participants: .
Note that the scoreboard will show your best score for each test among all your submissions.
Problem by Recraft
