From the Lab
SLIC Part 7 - Sigmoidal Brightness Transformations
Bernard Llanos — July 17, 2013 - 9:56am
The histogram-based brightness adjustments that I used earlier (http://gigl.scs.carleton.ca/node/532 and http://gigl.scs.carleton.ca/node/530) were limited by the range of brightness values in each SLIC segment of the image. I decided to try using a brightness mapping function instead, which takes the average brightness value of an SLIC segment and outputs a new brightness value that does not necessarily exist within the segment. Since I want to increase the tonal contrast of the image, I selected a sigmoidal brightness transformation function, a few variations of which are shown below:
As shown in the above figures, the average brightness of the source image is 75. The source image, shown below, is therefore a low-key image.
Source Image
Results of SLIC segmentation followed by a brightness adjustment
Brightness Offsets Method
When preparing the images used as the source colour data for averaging during crossfiltering, I had to decide how to combine SLIC and the sigmoidal brightness correction. The first method I tried was to assign a brightness offset to each pixel in an SLIC segment equal to the subtraction of the segment's average brightness from the transformed value of the segment's average brightness. I subsequently clipped pixel lightnesses to the range 0-255. The images below are the results of this process at a large SLIC region size (regionSize = 31, regularizer = 0.01), for the three sigmoidal curves shown above.
Brightness offset method with preservation of middle-grey lightness values
This image is very striking due to its lack of middle brightness values. As the source image was low-key, most of the pixels were shifted to very low brightness values. This had the unwanted effect of reducing detail as large areas of the image were compressed into a small tonal range.
Brightness offset method with conversion of average lightness values to a middle-grey lightness
With this brightness correction, the image's brightness histogram becomes much more uniform. The relatively even distribution of brightness values seems to improve the clarity of details and textures in the image.
Of particular interest in the above image are the edges which appear in the smooth central region of the orchid blossom. This is an artifact of using brightness offsets as opposed to assigning the same brightness value to all pixels within a segment. The same effect can be seen when using histogram-based brightness offsets (http://gigl.scs.carleton.ca/node/532). Basically, edges appear along the borders of SLIC segments which are part of the same colour gradient because pixels along these borders have similar lightness values, but get assigned different lightness offsets. Unfortunately, the shifts in brightness produce transitions along the borders of segments which are the reverse of the original colour gradient in the source image.
Brightness offset method with preservation of brightness values corresponding to the average image brightness
This last image is perhaps a good compromise between the first two images above, as it enhances the foreground-background contrast of the image without a severe loss of background detail.
Average Brightness Method
In addition to shifting the brightness of each pixel in a segment, I also tried assigning the transformed average brightness of the segment to all of the pixels in the segment. (This means that I overwrote the L* channel value of each pixel's colour in the CIE L*a*b* colour space.) The effect is perceptually quite similar to assigning a single value to all three colour channels of segment pixels, as done in previous posts. (See http://gigl.scs.carleton.ca/node/530, for example, ignoring the absolute lightness of segments and looking only at colour variation within segments.) The following three images are equivalent to the three images shown in the preceding section which discussed the brightness offset method (regionSize = 31, regularizer = 0.01).
Segment brightness averaging method with preservation of middle-grey lightness values
Segment brightness averaging method with conversion of lightness values equal to the average image lightness to a middle-grey lightness value
Note that assigning the same brightness value to all pixels in a segment does not result in the appearance of the unnatural edges and gradients on the cup of the orchid, unlike when pixels are given brightness offsets. The edges which do appear when assigning average lightnesses come instead from posterization. Therefore, the resulting lightness transitions conform to the gradients in the image.
Segment brightness averaging method with preservation of brightness values corresponding to the average image brightness
Cross-Filtering Results
Comparison of Lightness Offset and Lightness Average Methods
The following two images show the result of crossfiltering with a mask size of 256 and gamma parameter value of zero. The source image is used for filter mask generation, while the colours averaged to determine filtered pixel values come from an SLIC-segmented image (regionSize = 31, regularizer = 0.01) subject to the two brightness adjustment methods described above. The sigmoidal function used in the brightness adjustments is the version which preserves lightness values equal to the average image lightness.
Cross-filtering result obtained using an SLIC-segmented image with pixels given lightness offsets
Cross-filtering result obtained using an SLIC-segmented image with segments assigned transformed lightness values
I prefer the first image above (the lightness offset method) because the cumulative range geodesic filter is able to smooth over the edges introduced to the cup of the orchid during the lightness adjustment. The second image, which results from the method of assigning segment pixels a common lightness value, still shows fairly strong edges on the orchid flower corresponding to SLIC segment borders. Furthermore, much less detail is preserved in the second image than in the first. (This is evident from the appearance of the moss and the markings of the orchid blossom.)
Conclusion
Out of all brightness-adjusted cross filtering results relating to SLIC that I have discussed (Parts 3-4 and 6-7 blog posts), I prefer the use of a sigmoidal brightness transformation function of average segment brightness values to calculate brightness offsets applied to pixels in the corresponding SLIC segments. (This was the first brightness adjustment method discussed in this post.) My favourite image so far is the following:
This image was obtained by cross-filtering using the cumulative range geodesic filter at a mask size of 64 and a "gamma" parameter value of zero:
- The image used for building filtering masks is the original, non-segmented and unadjusted source image.
-
The image used for colour data (the colours averaged at the coordinates given by the filtering masks) was produced by SLIC segmentation of the source image (regionSize = 8, regularizer = 0.01).
- Following segmentation, the average lightness of each segment was computed and then converted to a transformed lightness using the third sigmoidal function shown in this post. (The sigmoidal function which maps the average lightness value of the entire image to itself.)
- The pixels in each segment were given a brightness change equal to the subtraction of their average brightness from their transformed average brightness.
(Image source: Bernard Llanos)