flag

This site uses cookies for statistical monitoring, 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.

Pre-processing

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.

Display

The extent of the palette (number of identified colors) is displayed using pictograms :
picto 31 - 60 colors
picto 61 - 90 colors
picto 91 - 120 colors
picto 121 - 150 colors
picto 151 - 180 colors
picto > 180 colors
Click here to display examples.

The chromatic dispersion is the average distance between the pixels of the picture and its average color in the chromatic space L*a*b*. This dispersion is displayed using pictograms :
picto 15 - 30
picto 30 - 45
picto 45 - 60
picto > 60
Click here to display examples.

Method 1 : color circle (top 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.

algorithm

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 chromas and their lightnesses (L*) in L*a*b* space.
When the angle is between 90° and 180°, the contribution is multiplied by the cosine of the angle.
The chromatic complementarity index is given by the contribution of all the pixels.
The maximum index (100%) is obtained for a picture of two colors with a maximum chroma and lightness, diametrically opposite on the chromatic circle  :

green-magenta

The complementarity index is displayed using pictograms :
picto 2.0 - 3.6 %
picto 3.6 - 6.5 %
picto 6.5 - 11.7 %
picto 11.7 - 21.0 %
picto 21.0 - 37.8 %
picto > 37.8 %
Click here to display examples.

Method 2 (top 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.

Contrast

The readability of a picture depends on the contrast between the different areas that make it up.
Two types of contrast can be defined :
◦ lightness contrast : when two nearby areas have different lightnesses, regardless of their chromas
◦ chromatic contrast : when two nearby areas have different chromas, regardless of their difference in lightness
The analysis consists of comparing each pixel with its neighbors and constructing an image of the differences using three methods :
◦ depending on the lightness gradient
◦ depending on the chroma gradient
◦ by combination of the two previous ones
The triple analysis of Monet's painting shows how the artist proceeded.

Monet - impressions soleil levant

A - lightness contrast
     The boat is visible but not the sun.
B - chroma contrast
     The boat is barely visible but the sun and the reddish reflections are.
C - contrast of lightness + chroma
     The boat and the red areas stand out from the bottom.


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