You are on page 1of 10

Contrast Limited Adaptive Histogram Equalization for Image Enhancement - OpenCV

Pi19404
February 2, 2013

Contents

Contents
Contrast Limited Adaptive Histogram Equalization for Image Enhancement 3

0.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . 0.2 Histogram Equalization . . . . . . . . . . . . . . . . . . 0.3 Adaptive Histogram Equalization . . . . . . . . . . . 0.4 Control Limited Adaptive Histogram Equalization 0.5 Application 1 . . . . . . . . . . . . . . . . . . . . . . . . . 0.6 Application 2 . . . . . . . . . . . . . . . . . . . . . . . . 0.7 Application 2 . . . . . . . . . . . . . . . . . . . . . . . . 0.8 Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . References . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

3 3 5 6 8 8 9 9 9

2 | 10

Contrast Limited Adaptive Histogram Equalization for Image Enhancement

Contrast Limited Adaptive Histogram Equalization for Image Enhancement


0.1 Introduction
Contrast Limited Adaptive Histogram Equalization is technique to enhance the images by improving the contrast of image.First we look at global histogram equalization, local histogram equalization,adaptive histogram equalization and variance of adaptive histogram equalization called Contrast Limited Adaptive Histogram Equalization.

0.2 Histogram Equalization


A Image is said to have good contrast if it has good color variance. A Image histogram is a good tool to analyze the contrast of the image. A Image Histogram is simply the count of pixel intensities organized into set of predefined bins A image with low contrast has histogram concenterated about some pixels while a image with high contrast has histogram that is equally spread over range of pixels. Below are histogram of low high contrast image.It can be observed that histogram is concenterated about few pixel values.Most of pixels in image lie in narrow range ,hence there is a low variance in pixel intensities .

(a) Low contrast Image

(b) Histogram

3 | 10

Contrast Limited Adaptive Histogram Equalization for Image Enhancement To produce a high contrast version of the image ,the task is to process the image such that histogram is more evenly distributed across all the pixel values,indicating the image contains a large variation of pixels indicating a high contrast image.It may lead to enhancing the unwanted noise and supressing desired information in image. These effects can be observed for images with very poor contrast such that histogram is very narrow,equalization will not transform the histogram to great extent by may lead in increasing the noise in the image The aim of histogram equalization tecnhiques is to apply some transformation of the image so that output image has increased contrast and histogram that is well distributed over the all range of pixels

(c) Low contrast Image

(d) Histogram

(e) High contrast Image

(f) Histogram

However this method has many disadvantages and produces artificial images under certain scenarois. Below are samples images for which histogram equalization produces image that introduces artifacts or leads to less visually appealing images. The main reason for these effects may be attributed to the fact that image transformation is performed considering the global histogram of image and the same transformation many not necessarily be suitable in local context . The histogram equalization also tends to produce visible gradients when applied to low contrast

4 | 10

Contrast Limited Adaptive Histogram Equalization for Image Enhancement images.

(g) Low contrast Image

(h) Histogram

(i) High contrast Image

(j) Histogram

Figure 1: Disadvantages of Equalization

0.3 Adaptive Histogram Equalization


Adaptive histogram equalization divides the image into several blocks .For each block histogram is computed and equalization if performed over the neighborhood. Generally neighborhood is choosen about a point and operation is performed for all points in the image. The parameter to control is the local neighborhood size.Too small a size will make will make it too sensitive to local variations and image noise and this will lead to artifacts . These effects are pronounced in regions which are homogenous ,regions with high frequency or noise The boundary between adjacent blocks are also clearly visible due to variation in local transformation function.To improve the image by providing a smooth variation of pixel values across adjacent blocks interpolation technique is used. The interpolated pixel is computed by using bi-linear interpolation of vaue of pixel in 3 neighboring blocks.

5 | 10

Contrast Limited Adaptive Histogram Equalization for Image Enhancement

The transformation function accepts a pixel intensity values and outputs a transformed pixel intensity value. Consider the block with size (A; B ) and co-ordinates (i 1; j 1) ,(i; j 1) ,(i 1; j ) and (i; j ) and let value of pixel according to transformation function in these blocks be v1,v2,v3,v4. The bilinear interpolation can be expressed as for pixel block 4
v

(x; y )

in

= (A

)( )
x B y

v1

+ (A

)
y x

v2

+ (A

)
x y

v3

+x

v4

For the block that lie along the boundary of the image linear interpolation is used Consider the block (i; 0) and (i 1; 0) if pixel corridnaties are such that x < A=2 and y < B=2 then
v

= (A

)
x

v1

+x

v2

Similarily for blocks along boundary in y direction


v

(0; j )

and

(0; j

1)

= (B

)
y

v1

+y

v2

The interpolation will reduce the boundary effects and provide smooth transition of pixel values between adjacent blocks of image.

0.4 Control Limited Adaptive Histogram Equalization


It can be observed that noise in enhanced in regions of low contrast using adaptive histogram equalization. For such regions a histogram clip limit can be defined.The histogram is clipped at the specified value and pixels are distributed to obtain a locally uniform histogram. The histogram value is maintained the same if not excess pixels are not added to it, however we clip all the pixels so as to obtain a relatively uniform historam indicating a image with good contrast.The transformation is computed using the clipped histogram. The histogram of adaptive equalization,interpolated and CLAHE are almost same. The only different is how they handel pixels at a local level.While interpolation provides smooth transition between adjacent blocks of pixels.

6 | 10

Contrast Limited Adaptive Histogram Equalization for Image Enhancement

The effect of clipping is to produce locally uniform histogram .The clipped level for all the blocks the transformation domain will be the same for all the blocks.The locally uniform histogram will give rise to locally good contrast image and the uniform clip level will give rise to a globally consistant image.

(a) Low contrast Image

(b) Histogram

(c) Equalize

(d) Histogram

(e) normalized

(f) Histogram

(g) Local HE

(h) Histogram

(i) interpolated

(j) Histogram

(k) CLAHE

(l) Histogram

Figure 2: Local Histogram Equalization

7 | 10

Contrast Limited Adaptive Histogram Equalization for Image Enhancement

0.5 Application 1
An application of CLAHE is for underwater image processing.First the color cast in under water image are removed using color constancy algorithm,then CLAHE is applied on the illumination channel of the color image.

(a) gray world

(b) CLAHE

(c) gray world

(d) CLAHE Figure 3: Application of CLAHE to image enchancementApplication 1

0.6 Application 2
If in the above approach the color cast is not removed successfully ,applying the CLAHE algorithm to the illumination channel does not help much in improving the contrast of the image. Another approach we can take is to apply CLAHE to RGB channels on the image independently choosing the clip level for each channel independently based on the requirement. In some situations it may be required to apply CLAHE to only one of RGB channels and Global histogram equalization is applied to other channels.In the below examples it can be seen that such processing is useful for enhancement of underwater images.

8 | 10

Contrast Limited Adaptive Histogram Equalization for Image Enhancement

(a) image

(b) CLAHE R

(c) global RGB

(d) CLAHE RGB

Figure 4: Application of CLAHE to image enchancementApplication 2

0.7 Code
Code is available in repository http://code.google.com/p/m19404/source/ browse/CLAHE/HistogramEqualization the implemetation is written in opencv using C++ wrappers and is same as OpenCv Code for Clahe and Code for Clahe with few minor modifications based on the above analysis.

9 | 10

Bibliography

Bibliography
[1] [2]

OpenCv Code for Clahe. url: https://github.com/joshdoe/opencv-clahe. Karel Zuiderveld. Code for Clahe. url: http://tog.acm.org/resources/
GraphicsGems/gemsiv/clahe.c.
Karel Zuiderveld.  Graphics gems IV. In: ed. by Paul S. Heckbert. San Diego, CA, USA: Academic Press Professional, Inc., 1994. Chap. Contrast limited adaptive histogram equalization, pp. 474485.

[3]

acm.org/citation.cfm?id=180895.180940.

isbn:

0-12-336155-9.

url: http://dl.

10 | 10

You might also like