You are on page 1of 5

FAST DYNAMIC RANGE COMPRESSION FOR GRAYSCALE IMAGES

Vasilios Vonikakis1, Ioannis Andreadis1 and Antonios Gasteratos2


1
Laboratory of Electronics, Section of Electronics and Information Systems Technology,
Department of Electrical and Computer Engineering,
Democritus University of Thrace, GR-671 00 Xanthi, Greece
E-mail: {bbonik, iandread}@ee.duth.gr
2
Laboratory of Robotics and Automation, Section of Production Systems,
Department of Production and Management Engineering
Democritus University of Thrace, GR-671 00 Xanthi, Greece
E-mail: agaster@pme.duth.gr

ABSTRACT between the original image and a gaussian-filtered version


of the original image, by computing their differences in a
This paper presents a new center-surround network for the logarithmic space. These ratios are used for the extraction
dynamic range compression of grayscale images. The of a lightness map which is independent from the scene
proposed method exploits some of the shunting illumination and depends only on the reflectances of
characteristics of biological center-surround networks, in objects in the scene. The algorithm is applied
order to reduce the effects of uneven illumination and independently to each chromatic channel and in three
improve the dynamic range of images. The main advantage different spatial scales. The final output is the weighted
of the proposed method is its low computational burden, sum of the three scales. The main advantage of Retinex is
which allows the rendition of high-resolution 5-MPixel the good dynamic range compression that achieves for a
images in approximately 1.3 seconds, when executed by a variety of different lighting conditions and the color
conventional personal computer. The method is compared constancy attributes that exhibits. It has been successfully
to the latest commercial version of the Retinex algorithm, used in many applications, such as shadow removal [6],
and exhibits promising results for a wide variety of real color correction [7] and gamut mapping [8]. The main
images and lighting conditions. weakness of Retinex is its computational burden, which
derives from the convolution of the image with Gaussian
filters of radiuses up to 240 pixels. Additionally, halo
1. INTRODUCTION effects tend to appear in regions where strong intensity
transitions exist, degrading the final output of the algorithm.
The dynamic range of natural scenes, that is, the ratio Other approaches to the dynamic range compression
between the maximum and minimum tonal values found in problem include the modeling of brightness perception [9],
the scene, can reach up to great proportions [1]. the manipulation of gradient in the luminance component
Conventional 8-bit cameras have a dynamic range of just [10] and the combination of images captured with different
256:1, while 14-bit high-end cameras can reach up to exposures [11, 12]. A detailed overview of dynamic range
16,384:1. This introduces an important problem to artificial compression techniques can be found in [13].
vision systems, especially when the dynamic range of the
scene exceeds the dynamic range of the camera. In these The proposed method is partially inspired by the HVS. It
cases, certain parts of the image can become either particularly adopts some of the shunting characteristics of
underexposured or overexposured, reducing the compound the on-center off-surround networks, in order to define the
visual information. Contrary to cameras, the human visual response function for a new artificial center-surround
system (HVS) can accommodate a dynamic range of network. This network compares every pixel to its local
approximately 10,000:1 [1]. This usually results into average and assigns a new value in order to light the dark
significant differences between the image perceived by the image regions, while minimally affecting the light ones.
HVS and the one captured by the camera. Histogram stretching is applied before the center-surround
network, ensuring that the final output occupies the full
Many algorithms have been presented in the past decade dynamic range of the medium. The proposed algorithm
that attempt to solve this problem. The most important of allows the rendition of high resolution 5-MPixel images in
all is the Retinex family of algorithms. Retinex was first approximately 1 second, even when executed by a
presented by Edwin Land in 1972 [2] and was inspired by conventional personal computer. Additionally, no multiple
some attributes of the HVS, which also defined its name scales are needed and no halo effects are introduced in the
(Retina & Cortex). The initial algorithm inspired many strong transitions between light and dark regions. The
others, the latest of which can be found in [3], while an algorithm exhibits good results for a wide variety of
extensive analysis of the algorithm can be found in [4,5]. images and lighting conditions without requiring additional
The main idea of Retinex is the calculation of ratios manual tuning. The evaluation of the proposed method is
carried out by comparing its outputs with the commercial dark image regions, the non-linearity ‘a*’ acts as a local
software PhotoFlair, which utilizes the Multi-Scale Retinex nonlinear correction: it gives a high output even when the
(MSR) algorithm, as presented in [3]. The results of the center has low values. This practically means that in dark
comparison show that the proposed method exhibits image regions, where illumination is not adequate, the cell
comparable and many times superior results to the Retinex increases its response to the contrast between center and
algorithm, in significantly lower execution times. surround, compensating for the low illumination. On the
contrary, for high surround values, which means that the
The rest of the paper is organized as follows: Section 2 cell is located in a light image region, the non-linearity ‘a*’
presents some of the attributes of the ganglion cells of the gradually vanishes to the almost-linearity ‘a’. As a result,
HVS upon which the proposed method is based and a the output of the cell is linearly associated with the contrast
detailed description of the algorithm. Section 3 between the center and the surround.
demonstrates the experimental results. Finally, concluding
remarks are made in section 4. Equation (1) possesses several characteristics, which make
it inappropriate for direct use in dynamic range
compression. First, it produces a bipolar output, since it is
2. DESCRIPTION OF THE METHOD essentially an edge detector. For this reason, it is usually
followed by half-way rectification and a filling-in
It is long known that a shunting on-center off-surround procedure [16] which is time consuming. Second, the
network of cells can reduce the effects of illumination output range is reduced to half ‘b’, as the surround values
(discount the illuminant) and extract the scene reflectances progress from low to high. In order to overcome these
by adapting to a wide range of inputs [14, 15]. These drawbacks, equation (2) is used as a basis, which describes
attributes are the result of a biological adaptation the total activity of a shunting center-surround network
mechanism known as ‘shunting inhibition’. The steady [14]. It is then modified in order to eliminate the unwanted
state solution of the shunting differential equation, that output reduction ‘b’. The resulted function is equation (3).
shows the output of an on-center off-surround cell, when t The graphical representations of both equations (2) and (3)
→ ∞, is shown in equation 1. are depicted in Fig. 2.

C-S B⋅ x
out ( C,S) = (1) F(x) = (2)
g leak + C + S A+x

where C is the value of the center, S is the value of the G(x) =


(B + A )⋅ x (3)
surround and gleak is the decay constant. When used in A+x
image processing applications, gleak usually is the
maximum value that a pixel may take, which in our case is
255. The 3-dimensional representation of equation (1) for
an on-center off-surround cell with 0 ≤ C ≤ 255 and 0 ≤ S ≤
255 is depicted in Fig. 1.

Figure 1: The 3-dimensional representation of equation (1).


Figure 2: Graphical representation of equations (2) and (3).
The reason for which a center-surround cell with equation
(1) as an activation function can discount the illuminant is In equations (2) and (3), B is the maximum value the
evident in Fig. 1. In fact, equation (1) performs a function can take and A is a constant that determines the
comparison of the contrast between the center and the degree of non-linearity. Equation (3) transitions from a
surround and adequately adjusts the output. For low sharp non-linearity (A=1) to a linearity (A≥1000), while
surround values, which means that the cell is located in maintaining the same output range 0 ≤ G(x) ≤ B for all the
possible values of A. If x is substituted by the center C of a
py px
center-surround cell and the surround S is correlated with (8)
the non-linearity factor A, a new, improved response ∑∑ u (85-p )
i=1 j=1
i,j

function is formed. Since the maximum response of the r= ×100


px×py
cell must be equal to the maximum value of a pixel, B=255.
190
The following equations describe the activation function of m= (100 − r ) + 10 (9)
the center-surround cell of the proposed method. 100

C i,j,t + 1 (C ,S ) =
( 255 + A (S ) ) ⋅ C i,j i,j,t (4) Where u(x) is the unit step function (is 1 if x≥0 and 0 if
A ( S i,j ) + C i,j,t x<0), px, py are the dimensions of image and pi,j the pixel
value at position (i, j). The main idea is to calculate the
A(S i,j ) = S i,j + m + q ( S i,j ) (5) percentage of pixels in the image that have values below
85. This is a rough estimation of the darkness in the image
255 ⋅ Si,j and therefore it is used to adjust the minimum value ‘m’
q(Si,j ) = (6)
255-Si,j that the non-linear factor A can obtain. Equation (9)
linearly regulates the value of ‘m’, between 10, when
1 i+1 j+1 100% of the image pixels are below 85 and 200, when 0%
Si,j = ∑ ∑ py,x
9 y=i-1 x= j-1 (7) of the image pixels are below 85. Constant 85 was selected
as it is the 1/3 of 255 and can be thought of as the first bin
Where, (i, j) denote the coordinates of a pixel in the image of a 3-bin histogram that divides the 255 intensities into 3
and p is its value. In the proposed method, the surround Si,j sets: dark, medium and light.
is the average of a 3×3 pixel region while the center Ci,j is
the central pixel of this region. Equation (5) describes the In order to achieve better results, a histogram clipping and
non-linearity factor A, as a function of the surround. The stretching technique is required, prior to processing with
minimum value obtained by A(S), when S=0, is denoted by the center-surround network. The technique is the one that
‘m’. This non-linearity affects the overall result of the has been extensively discussed in [4] and for this reason it
algorithm and its value is determined by the statistics of the is not described here.
image. Equation (6) describes the transition between the
non-linearity ‘a*’ and the linearity ‘a’, as the surround
values increase. Fig. 3 shows the 3-dimensional 3. EXPERIMENTAL RESULTS
representation of equation (4).
The proposed method is compared to the MSR algorithm,
extensively described in [3]. The MSR algorithm is
generally used for color constancy applications. However,
in the present study only its dynamic range compression
characteristics are compared, by applying it only on
grayscale images. The implementation of the MSR
algorithm that was used for the tests was the commercial
software PhotoFlair that features the MSR algorithm. The
parameters of the MSR were the default that the authors
have mentioned (3 scales with radiuses 5, 20 and 240
pixels and equal weights for every scale). The proposed
method was implemented in C code. Both algorithms were
executed on an Intel Pentium 4 processor, running at 3GHz,
with 512 MB RAM and Windows XP.
Figure 3: The 3-dimensional representation of equation (4).
3.1 Results with Real Images
The new activation function maintains the transition from
the non-linearity ‘a*’ to the linearity ‘a’ correlated with the This subsection presents the results of the comparison
value of the surround. This means that when the surround between the MSR and the proposed algorithm, in a set of
has low values, something occurring in dark image regions, real high-resolution grayscale images. Most of the images
the non-linearity ‘a*’ increases the value of the center in represent scenes that were captured with different digital
order to increase the local contrast. On the contrary, when cameras under different lighting conditions where dynamic
the surround comprises high values, something that range correction is required. Table 1 exhibits some of the
happens in light image regions, the linearity ‘a’ does not results that were obtained by the proposed method and
alter the value of the center. For all the intermediate MSR. For every image, its size and the execution times of
surround values, equation (6) determines the degree of the two methods are included. It is important to mention
non-linearity. that the PhotoFlair software that was used to obtain the
MSR outputs has 3 different versions of the Retinex
The calculation of ‘m’ in equation (5) is as follows: algorithm: Scenic Retinex, Portrait Retinex and Portrait
Retinex followed by ‘auto levels’, which is a form of
histogram equalization. The Retinex results that are shown
in Table 1 are always the best of the 3 versions, as selected 3.2 Quantitative Comparison
by the typical human observer.
The following experiment was carried out in order to
It is evident from the results that the proposed method can achieve a numerical comparison between the two
correct most of the problems caused by the limited algorithms. Different levels of a computer generated
dynamic range of the camera. Additionally, all images shadow were embedded in a real image that had otherwise
demonstrate the main advantage of the proposed method no need for dynamic range correction. The shadow level
over MSR; the lack of halo effects. Most of the regions that was determined by the factor ‘sh’, ranging between
MSR fails to restore are the result of significant halo 50%-95%. Half of the image pixels were multiplied by
effects which are caused in the boundaries of a dark region 1-(sh/100), thus producing a shadow in half of the image.
with a light one. The execution times of the proposed Fig. 4 shows some of the computer generated shadows, as
method are approximately 23 times lower than the ones well as the outputs for these particular images.
required for the MSR, allowing the rendition of 5-MPixel
images in 1.3 sec. It should not be neglected though, that
MSR preserves better the light regions of the image, while
the proposed method tends to light them more than
necessary.

Original MSR Proposed Original image sh = 50% sh = 80%

Proposed

Retinex
1. 1920×2560 30 sec 1.3 sec

Figure 4: The original image and two examples of the


computer generated shadows, as well as results for these
examples.
2. 2560×1920 29 sec 1.3 sec

3. 2560×1920 30.5 sec 1.4 sec

4. 2304×1728 25.7 sec 1.1 sec

5. 1728×2304 27 sec 1.1 sec

6. 2560×1920 31.7 sec 1.4 sec Figure 5: Results from the comparison for different shadow
Table 1: Comparison of results of the proposed method levels.
with MSR in real images.
The results of the two algorithms were compared to the 5. REFERENCES
original image by the use of two metrics. The first was the
average difference, which is the sum of the pixel [1] K. Devlin, “A Review of Tone Reproduction
differences divided by the total number of pixels. The Techniques,” Technical Report CSTR-02-005,
second was the average squared difference, which is the University of Bristol, 2002.
sum of the squared pixel differences divided by the total [2] E. Land and J. McCann, “Lightness and Retinex
number of pixels. The first metric gives an overall Theory,” Journal of the Optical Society of America,
impression of the difference of the two images. The second Vol. 61. No.1.pp. 1-11, 1971.
metric assigns more weight to bigger differences than [3] D. Jobson, Z. Rahman, and G. Woodell, “A Multi-Scale
smaller ones, due to the presence of the square. It is thus Retinex For Bridging the Gap Between Color Images
more sensitive to big differences, such the ones derived by and the Human Observation of Scenes,” IEEE
unwanted halo effects. Fig. 5 shows the results of the Transactions on Image Processing: Vol. 6.pp. 965-976,
comparison. All the 3 versions of Retinex were tested. 1997.
The Retinex images that are shown in Fig. 4 are the best of [4] D. Jobson, Z. Rahman, and G. Woodell, “Properties and
the 3 versions, as selected by the typical human observer. Performance of a Center/Surround Retinex,” IEEE
The results of the experiment show that the proposed Transactions on Image Processing, Vol. 6.pp. 451-462,
method outperforms all the 3 versions of the MSR for both 1997.
the metrics and for all the shadow levels. [5] K. Barnard and B. Funt, “Investigations into
Multi-scale Retinex,” Color Imaging: Vision and
Technology, pp. 9–17, 1999.
4. CONCLUSIONS [6] G. Finlayson, S. Hordley and M. Drew, “Removing
Shadows from Images using Retinex,” Color Imaging
This paper presents a new algorithm for fast dynamic range Conference, pp. 73-79, 2002.
compression. The proposed algorithm exploits some of the [7] D. Marini and A. Rizzi, “A Computational Approach to
characteristics of the shunting on-center off-surround Color Adaptation Effects,” Image and Vision
networks of the HVS. A new activation function has been Computing Vol. 18. pp. 1005-1014, 2000.
introduced that compensates for the low illumination in the [8] J. McCann, “Lessons Learned from Mondrians Applied
dark image regions and enhances the contrast. to Real Images and Color Gemuts,” The Seventh
Color Imaging Conference, Color Science, Systems
The main advantage of the proposed method is its fast and Applications, pp. 1-8, 1999.
execution. The major reason for this is the fact that the [9] V. Brajovic, “Brightness Perception, Dynamic Range
method avoids computationally intensive convolutions and and Noise: A unifying model for adaptive image
computes the new pixel values by processing a 3×3 sensors,” CVPR’04 Vol 2. pp. 189-196, 2004.
neighborhood. On the contrary, MSR, as presented in [3, 4], [10] R. Fattal, D. Lischinski and M. Werman, “Gradient
is based on the convolution of the original image with Domain High Dynamic Range Compression,” 29th
Gaussian filters of large radiuses, ranging up to 240 pixels. International Conference on Computer Graphics and
Consequently, it is much more computationally expensive Interactive Techniques (SIGGRAPH), 2002.
than the proposed method. This is reflected also in the [11] P. Debevec and J. Malik, “Recovering high dynamic
results, where the proposed method renders the test images range radiance maps from photographs,” SIGGRAPH
approximately 20 times faster than MSR. The reader can 97, pp. 369– 378, 1997.
assess the quality of the results of the proposed method, [12] S. Nayar and T. Mitsunaga, “High Dynamic Range
which is at least comparable with that of MSR. When Imaging: Spatially Varying Pixel Exposures,” IEEE
strong transitions between dark and light image regions Conference on Computer Vision and Pattern
occur, MSR tends to exhibit halo effects, whereas the Recognition Vol. 1. pp. 472 – 479, 2000.
proposed method does not. A numerical assessment to [13] S. Battiato, A. Castorina, and M. Mancuso, “High
quality was also carried out to confirm these conclusions. dynamic range imaging for digital still camera: an
overview,” Journal of Electronic Imaging Vol. 12. pp.
However, it should be mentioned that the proposed method 459-469, 2003.
tends to light the correct image areas more than necessary, [14] S. Ellias and S. Grossberg, “Pattern Formation,
whereas the MSR does not. This can be justified due to the Contrast Control and Oscillations in the Short Term
fact that all the results and tests were carried out without Memory of Shunting On-Center Off-Surround
manual tuning. This is important because it shows that the Networks,” Biological Cybernetics Vol. 20. pp. 69-98,
proposed method can achieve satisfactory results for a 1975.
wide variety of images, without any supervision. Taking [15] S. Grossberg, “Visual Boundaries and Surfaces,” The
also into account its simplicity and the short execution Visual Neurosciences Vol. 2, MIT press, 2004.
times, the algorithm it can be used in time-critical [16] E. Mingolla, W. Ross and S. Grossberg, “A Neural
applications that require automatic dynamic range Network for Enhancing Boundaries and Surfaces in
compression. Synthetic Aperture Radar Images,” Neural Networks
Vol. 12. pp. 499-511, 1999.