0% found this document useful (0 votes)
52 views

Histogram Processing: Enhancement Through Histogram Manipulation

Histogram equalization is an automatic image enhancement technique that redistributes the brightness values of pixels in an image to increase contrast. It transforms the image's histogram to a uniform distribution, resulting in a wider range of brightness levels across the output image. However, histogram equalization does not always produce good results, such as when the original image histogram is heavily skewed toward dark or light pixels. Histogram matching is another histogram manipulation technique that can be used for image enhancement.

Uploaded by

nimra sohail
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Histogram Processing: Enhancement Through Histogram Manipulation

Histogram equalization is an automatic image enhancement technique that redistributes the brightness values of pixels in an image to increase contrast. It transforms the image's histogram to a uniform distribution, resulting in a wider range of brightness levels across the output image. However, histogram equalization does not always produce good results, such as when the original image histogram is heavily skewed toward dark or light pixels. Histogram matching is another histogram manipulation technique that can be used for image enhancement.

Uploaded by

nimra sohail
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Histogram Processing

Enhancement through Histogram Manipulation


Histogram manipulation aims to determine a gray-level transform that
produces an enhanced image that has a histogram with desired properties.
We study two histogram manipulation techniques namely Histogram
Equalization (HE) and Histogram Matching (HM).

Histogram Equalization
is an automatic enhancement technique which produces an output
(enhanced) image that has a near uniformly distributed histogram.
For continuous functions, the intensity (gray level) in an image
may be viewed as a random variable with its probability density function
(PDF). The PDF at a gray level r represents the expected proportion
(likelihood) of occurrence of gray level r in the image. A transformation
function has the form

Page 1
Image Processing

s = T(r) = (L - 1) J Pr(w) dw

where w is a variable of integration. The right side of this equation is


called the cumulative distribution function (CDF) of random variable r.
For discrete gray level values, we deal with probabilities (histogram
values) and summations instead of probability density functions and
integrals. Thus, the transform will be:

L L
k k

sk = T(rk) = (L - 1) Pr(1}) = (L - 1) M� N
j=O j=O
k
= (L- l)�n- k = 0, 1 , 2 , ... , L - 1
Mx NL 1
j=O

The right side of this equation is known as the cumulative histogram for
the input image. This transformation is called histogram equalization or
histogram linearization.
Because a histogram is an approximation to a continuous PDF, perfectly
flat histograms are rare in applications of histogram equalization. Thus,
the histogram equalization results in a near uniform histogram. It spreads
the histogram of the input image so that the gray levels of the equalized
(enhanced) image span a wider range of the gray scale. The net result is
contrast enhancement.

Page 2
Image Processing

Example:
Suppose that a 3-bit image (L =8) of size 64 x 64 pixels has the gray
level (intensity) distribution shown in the table below.

rk nk
ro =0 790
r1 =1 1023
r2= 2 850
r1 =3 656
r4= 4 329
r5 =5 245
r6 6
=
122
r 7 =7 81

Perform histogram equalization on this image, and draw its normalized


histogram, transformation function, and the histogram of the equalized
image.

Solution:
M x N =4096
We compute the normalized histogram:

rk nk Pr (rk ) = n k /MN
ro= 0 790 0.19
r1 =1 1023 0.25
r2 =2 850 0.21
r3 =3 656 0.16
r4 =4 329 0.08
r5 =5 245 0.06
r6 6 =
122 0.03
r7 =7 81 0.02

Page 3
Image Processing

.25

. 20
. 15 : .
.IO
.05 •
0 2 3 4 5 6 7
Normalized histogram

Then we find the transformation function:

sk = T(rk) = (L - 1) _L Pr(71)
j=O

So = T(ro) = 7 _L P (71) = 7pr(r ) = 1.33


r o
j=O

S1 = T(r1 ) = 7 _L P ( ) = 7pr(r
r 7i 0) + 7p r (r1 ) = 3.08
J=O

and s2 = 4.55, s3 = 5.67, s4 = 6.23, s5 = 6.65, s6 = 6.86, s7 = 7.00

7.0 · - · --- ·
.'i.6
4.2
2.8
1.4

0 1 2 3 4 .'i 6 7
Transformation function
We round the values of s to the nearest integer:
So = 1.33 ➔ 1 S1 = 3.08 ➔ 3 Sz = 4.55 ➔ 5
S3 = 5.67 ➔ 6 S4 = 6.23 ➔ 6 S5 = 6.65 ➔ 7
s6 = 6.86 ➔ 7 S7 = 7.00 ➔ 7

Page 4
Image Processing

These are the values of the equalized histogram. Note that there are only
five gray levels.

rk nk Sk Newn k p5 (sk ) = New nk /MN


ro 0
=
790 So 1
=
790 0.19
r1 = 1 1023 SJ 3
=
1023 0.25
r2 = 2 850 S2 = 5 850 0.21
r3 = 3 656 S3 = 6 985 0.24
r4 =
4 329 S4 = 6
r5 =5 245 S5 = 7 448 0.11
r6 6=
122 s6 = 7
r7 7=
81 S7 = 7

Thus, the histogram of the equalized image can be drawn as follows:

P.,(sk)

.25 • •'
. 20 • ''
•''
'
.15
'
.Hl
'
.05
sk
2 3 4 5 6 7
Histogram of equalized image

The next fi gure shows the results of performing histogram equalization


on dark, light, low-contrast, and high-contrast gray images.

Page 5
Image Processing

Figure 1 Left column original images. Center column corresponding histogram equalized
images. Right column histograms of the images in the center column.

Page 6
Image Processing

Although all the histograms of the equalized images are different, these
images themselves are visually very similar. This is because the
difference between the original images is simply one of contrast, not of
content.
However, in some cases histogram equalization does not lead to a
successful result as shown below.

X 10

250

(a) Original image (b) Histogram of(a)


Figure 2 Image of Mars moon and its histogram

The result of performing histogram equalization on the above image is


shown in the fi gure below.

0 50 100 150 200 250


(a) Result ofapplying HE (b) Histogram of(a)
Figure 3 Result of applying HE on Figure 5.9 (a)

Page 7
Image Processing

We clearly see that histogram equalization did not produce a good result
in this case. We see that the intensity levels have been shifted to the upper
one-half of the gray scale, thus giving the image a washed-out
appearance. The cause of the shift is the large concentration of dark
components at or near O in the original histogram. In tum, the cumulative
transformation function obtained from this histogram is steep, as shown
in the fi gu re below, thus mapping the large concentration of pixels in the
low end of the gray scale to the high end of the scale.
255

.!!l 192

� 128
';:i
';:i 64
0

64 128 192 255


Input gray levels
Fi gure 4 HE transformatio n functio n of Fi gure 5. lO(a)

In other cases, HE may introduce noise and other undesired effect to the
output images as shown in the fi gu re below.

(a) Origni al i mage (b) ResultofapplyingHEon(a)

Page 8
Image Processing

( d) Result of applying HE on (c)


Figure 5 Undesired effects caused by HE

These undesired effects are a consequence of digitization. When digitize


the continuous operations, rounding leads to approximations.
From the previous examples, we conclude that the effect of HE differs
from one image to another depending on global and local variation in the
brightness and in the dynamic range.

Histogram Matching (Specification)


is another histogram manipulation process which is used to generate a
processed image that has a specified histogram. In other words, it enables
us to specify the shape of the histogram that we wish the processed image
to have. It aims to transform an image so that its histogram nearly
matches that of another given image. It involves the sequential
application of a HE transform of the input image followed by the inverse
of a HE transform of the given image.

The procedure of Histogram Specification is as follows:


1. Compute the histogram Pr (r) of the input image, and use it to find
the histogram equalization transfom1ation using

Page 9
Image Processing

k
= (L- l)�n-
k = 0, 1, 2 , ... , L - 1
M x N Li 1
j=O

Then round the resulting values, sk, to the integer range [O, L-1].
2. Compute the specified histogram Pz (z) ofthe given image, and use
it find the transformation function G using

G(zq ) = (L -1) LPz (zi) q = 0,1,2, ... ,L -1


i=O

Then round the values of G to integers in the range [O, L-1]. Store
the values of G in a table.
3. Perform inverse mapping. For every value of sk , use the stored
values of G from step 2 to find the corresponding value of Zq so
that G(zq ) is closest to sk and store these mappings from s to z.

When more than one value of Zq satisfies the given sk (i.e. the
mapping is not unique), choose the smallest value.
4. Form the output image by first histogram-equalizing the input
image and then mapping every equalized pixel value, sk , ofthis
image to the corresponding value Zq in the histogram-specified
image using the inverse mappings in step 3.

Page 10
Image Processing

Example:
Suppose the 3-bit image of size 64 x 64 pixels with the gray level
distribution shown in the table, and the specified histogram below.

rk nk Pt ( Zq)

r0 = 0 790 .30 !
:
r1 = 1 1023 .25
r2 =2 850 .20 • •
r3 =3 656 .15 • ' •
r4 =4 329 .10 ;

r5 = 5 245 .05
r6= 6 122 Zq
I 2 3 ➔ 5 6 7
r 1= 7 81

Perform histogram specification on the image, and draw its normalized


histogram, specified transformation function, and the histogram of the
output image.

Solution:
Step 1:
M x N =4096
We compute the normalized histogram:

rk nk Pr(rk ) = nk /MN
ro= O 790 0.19
r1 =1 1023 0.25
r2 2
=
850 0.21
r3 =3 656 0.16
r4 =4 329 0.08
r5 = 5 245 0.06
r6= 6 122 0.03
r 7 =7 81 0.02

Page 11
Image Processing

.25

. 20
. 15 : .
.IO
.05 •
: • ,-k
0 3 4 5 6 7

Normalized histogram

Then we find the histogram-equalized values:

_L Pr(1j')
k

sk = T(rk) = (L - l)
j=O

So = T(ro) = 7 _L Pr( ) = 7p (r ) = 1.33


1j r o
j=O

S1 = T(r1 ) = 7 _L Pr(1j) = 7pr(r 0) + 7p r (r1 ) = 3.08


j=O

and s2 = 4.55, s3 = 5.67, s4 = 6.23, s5 = 6.65, s6 = 6.86, s7 = 7.00


We round the values of s to the nearest integer:

So = 1.33 ➔ 1 S1 = 3.08 ➔ 3 Sz = 4.55 ➔ 5


S3 = 5.67 ➔ 6 S4 = 6.23 ➔ 6 S5 = 6.65 ➔ 7
s6 = 6.86 ➔ 7 S7 = 7.00 ➔ 7

Step 2:
We compute the values of the transformation G

Page 12
Image Processing

L
0

G(z0 ) =7 p2 (zJ =0
i=O

L
1

G(z1 ) = 7 p2 (z i ) = 7[p(z0 ) + p(z1 )] = 0


i=O

and G(z2 ) = 0 , G(z3 ) = 1.05 , G(z4 ) = 2.45


G(z5 ) = 4.55 , G(z6 ) = 5.95 , G(z7 ) = 7.00

We round the values of G to the nearest integer:


Zq G(zq ) G(z q )
Zo = Q 0 7
ZJ = 1 0 6
z2= 2 0 5
Z3 =3 1 4
Z4 =4 2 3
2
Z5 = 5 5 1
z6 = 6 6
Z7= 7 7 0 1 2 3 4 5 6 7
Transformation function obtained
from the specified histogram

Step 3:
We find the corresponding value of Zq so that the value G(zq ) is the
closest to sk

Sk Zq
1 �
� 3
3 4
::
5 5
6 :: 6
7 7

Page 13
Image Processing

Step 4:
rk nk Sk Newn k ps (sk ) = New nk /MN
ro = 0 790 So =
3 790 0.19
r1 = 1 1023 SJ = 4 1023 0.25
r2 = 2 850 S2
=5 850 0.21
r3 = 3 656 S3 = 6 985 0.24
r4 =
4 329 S4 = 6
r5 =5 245 S5 = 7 448 0.11
r6 = 6 122 s6 = 7
r7 = 7 81 S7 = 7

Thus, the histogram of the output image can be drawn as follows:


Pz(Zq)

.25 • •

'

.20
I
'

.15
. 10
.05
Zq
() 1 2 3 4 5 6 7

To see an example of histogram specification we consider again the


image below.

50 100 150 200 250


(a) Original image (b) Histogram of(a)
Figure 6 Image of Mars moon and its histogram

Page 14
Image Processing

We use the following specified histogram shown in the fi gure below to


perform histogram specification on the image in the previous fi gure.

Figure 7 Specified histogram for image in Figure 6(a)

The output image of histogram specification is shown below.

50 100 200 250

(a) Result of applying HS (b) Histogram of(a)


Figure 8 Result of applying HS on Figure 6 (a)

Page 15

You might also like