From the Lab
SLIC Part 4 - Brightness-Shifted Average Colours (Histogram-Based Adjustment)
Bernard Llanos — July 15, 2013 - 10:50am
I experimented with another variation on the crossfiltering approach described at http://gigl.scs.carleton.ca/node/528. As before, pixels in an SLIC segment are assigned the average hue of the segment. However, the lightness component of the colour assigned to the segment is set equal to a given percentile of the lightness values of the pixels in the segment. (All lightness values were measured in the CIE L*a*b* colour space.)
The intention of this approach is to enhance the lightness contrast of the image. To achieve this goal, I set the new colour's lightness value equal to the nth percentile of segment lightness values if the average lightness of the segment is above the average lightness of the image. Conversely, the average lightness of the segment is below the average lightness of the image, I set the new colour's lightness equal to the (100-n)th percentile of segment lightness values.
As with the method of weighting segment pixels during averaging (see http://gigl.scs.carleton.ca/node/529), undesirable results occur if I use a lightness value of middle grey to decide whether to shift the lightness of a segment up or down. Therefore, all crossfiltering results in this post use the average lightness of the image as a threshold value instead of middle grey.
Segmented image assigned average hues and 99th-percentile lightnesses (regionSize = 31, regularizer = 0.01)
The above image shows how the segmentation, averaging, and lightness-shifting procedure result in a high contrast image. A fairly large percentile value is necessary to obtain a significant increase in tonal contrast.
Unfortunately, at larger values of the SLIC regionSize parameter, a higher percentile value used for lightness-shifting results in a loss of colour saturation. Under these conditions, there is also a loss of detail (texture) in regions with little initial tonal contrast, giving the impression of posterization in some areas.
These side effects are demonstrated in the following three images. Note that the third image, produced by averaging pixels in SLIC segments without any lightness shifting, has the lowest tonal contrast, but the second-lowest overall colour saturation. Also note that, in the first image, the leaf on the left border is barely visible.
Cross-filtering of a segmented image with averaged, lightness-shifted colours (percentile = 99, regionSize = 31, regularizer = 0.01, mask size of 1024 pixels, gamma parameter value of zero)
Basic cumulative range geodesic filtering (mask size of 1024 pixels, gamma parameter value of zero)
Cross-filtering of a segmented image with averaged, non-lightness-shifted colours (regionSize = 31, regularizer = 0.01, mask size of 1024 pixels, gamma parameter value of zero)
Preferred Cross-Filtering Settings
My favourite cross-filtering result from the last three posts (which discussed averaging colours within SLIC segments) is obtained with a small segment size, a small mask size, and lightness shift which uses a high percentile value. As shown in the first image below, the image appears very bold and the flower retains its bright specular highlights, which make up for the loss of colour saturation.
Cross-filtering of a segmented image with averaged, lightness-shifted colours (percentile = 94, regionSize = 8, regularizer = 0.01, mask size of 64 pixels, gamma parameter value of zero)
Source Image
Basic filtering at a mask size of 64 pixels and gamma parameter value of zero
(Image source: Bernard Llanos)