This site uses cookies for statistical monitoring, performance and security, as well as for fb_page buttons, and does not use personal data

Chromatic analysis algorithm (*)

The analysis consists of three stages : preparation for processing, determination of a representative palette (or "color quantification") and its display.


The final result obviously depends on the quality of the initial images.
Many very old works have missing or degraded parts. This is often the case with the ancient frescoes delivered by archeology. These images must be cropped to keep only the representative areas.
Even well-preserved works sometimes have to be cropped because of shadows around the edges.
Then, many paintings appear yellowed due to the ageing of the varnish or poor shooting conditions. It is therefore useful to use photo editing software to refresh the colors. There is obviously no guarantee that the result will be perfectly in line with the original work, but the improvement is comparable to painting restorations by specialized workshops.
The images on this site result from this processing. A click on the image shows the initial image.
Finally, the images are resampled to about 10,000 pixels : a painting of one square meter is therefore represented by pixels of one centimeter on the side. This simplification shortens the processing time and has little influence on the final result.

Color quantification

The general principle is to establish a statistic of the different pixel colors.
Computer color display uses 3-D coding : the RGB system, which drives the screens using 3 numbers between 0 and 255, which defines 16,777,216 colors. In practice, a picture usually has thousands of different colors, the raw statistics of which would be of little use.
It is therefore necessary to group them together to obtain a sample that can be thought of as resembling the painter's palette.
This statistic can be established in the RGB space, but it does not adequately reflect human perception. A better chromatic space is the L*a*b* system developed by the International Commission on Illumination.
The algorithm consists in converting the pixels from RGB to L*a*b* and classifying them into a cube of 1000 cells obtained by splitting the 3 axes L, a and b into 10 segments. The 16,777,216 possible RGB colors occupy only 415 cells of this cube. Applied to a painting, this method gives a palette generally between 50 and 150 colors  ; only very variegated photos exceed 200.
For each cell of this cube, the algorithm counts the number of pixels and calculates the average RGB values of the analyzed image.


The number of colors identified in the picture is displayed using pictograms :
picto 30 - 60 couleurs
picto 60 - 90 couleurs
picto 90 - 120 couleurs
picto 120 - 150 couleurs
picto 150 - 180 couleurs
picto > 180 couleurs
Click here to display examples.

The extent of the pictorial palette is evaluated by means of a concept of chromatic standard deviation defined as follows : average distance between the pixels of the picture and its average color, in the chromatic space L*a*b*. This extent is displayed using pictograms :
picto 15 - 30
picto 30 - 45
picto 45 - 60
picto > 60
Click here to display examples.

Method 1 : color circle (in the center on the pages of the site)

The color circle, well known to artists, offers the advantage of showing complementary colors but presents the difficulty of displaying a 3-D space on a plan.
The colors quantified in the previous step are converted into HSV (hue-saturation-value) :
◦ hue : angle between 0° and 360° on the chromatic circle
◦ saturation : degree of purity in relation to the corresponding vivid color (0 = gray ; 100 = vivid color)
◦ value: light intensity (0 = dark ; 100 = bright)
The algorithm uses the hue as the angular coordinate and the value as the radial coordinate.
Saturation is given implicitly by the color of the disc, the diameter of which depends on the number of pixels in the image.
The colors with the most pixels are in the background. They can be partially (or even totally) masked by a multitude of less frequent colors having similar hue and value. For this reason, the algorithm limits the number of colors displayed to 128.
The second method does not have this drawback.

A chromatic complementarity index is calculated by adding the contribution of each pair of pixels in the picture.


When the angle between two pixels on the color circle is less than 90°, their contribution to the index is zero: their colors are not at all complementary.
When two pixels are located on the same diameter on either side of the center, their contribution depends on their values (= light intensity) and their saturations.
When the angle is between 90° and 180°, the contribution is multiplied by the cosine of the angle.
For the figure above, the contribution of a pair of red/green pixels is  : (1 × 1 × 0,65 × 0,91)² × 0.875 = 0.31
The chromatic complementarity index is given by the contribution of all the pixels, divided by the average value of the picture.
The maximum index (100%) is therefore obtained for a picture of two equally important colors (50% / 50%) with a maximum value and saturation, and diametrically opposite on the chromatic circle, e.g. :


The complementarity index is displayed using pictograms :
picto 0.2 - 0.4 %
picto 0.4 - 0.8 %
picto 0.8 - 1.6 %
picto 1.6 - 3.2 %
picto 3.2 - 6.4 %
picto > 6.4 %
Click here to display examples.

Method 2 (on the right on the pages of the site)

Colors are displayed in horizontal strips according to their proximity in L*a*b* space, starting with the one with the most pixels. Two cells are "close" if they have adjacent faces, edges or vertices : so each strip has at most 27 colors.
This method has the advantage of correctly displaying all the colors of the palette.

(*) The fine-tuning of the algorithm benefited from the advice of Vinciane Lacroix.