Professional Documents
Culture Documents
Definition
Histogram equalization is a technique of image processing about contrast
adjustment using the images histogram.
It is not necessary that the contrast in an image will always be increase in this
method. Through the adjustment, the intensities can be better distributed over the
histogram. This allow the area of lower contrast to gain a higher contrast and vice
versa. Histogram equalization is done by spreading out the most frequent intensity
values.
This method is useful in images with backgrounds and foregrounds are both bright
or dark.
The key advantage of this method is that it is a straightforward technique and is an
invertible method. In theory, if the histogram equalization function is known, then
the original histogram can be recovered. The most disadvantage of this method is
that it may decrease the contrast of the usable signal and in turn increase the
contrast of noise.
In order to implement this method, let first clarify some notations:
pr ( r )
and
ps ( s )
Figure 2: An arbitrary PDF and the result of apply transformation to all intensity level. The intensity s
has a uniform PDF and is independent of the PDF of r.
Figure 3: (a) Monotonically increasing function, multiple values can map to a single value and (b)
Strictly monotonically increasing function, a one-to-one mapping.
Choose:
r
ds dT (r ) d
=
=
(L1) pr ( w ) dw =( L1) p r ( r )
dr
dr
dr
0
From the property of the PDF for s=T(r):
ps ( s ) ds=p r ( r ) dr
p s ( s) =
pr ( r ) dr
pr ( r )
1
=
=
ds
( L1) pr ( r ) ( L1)
So, the power density function of the newly generated histogram is uniform. The
chosen T(r) is correct.
For the discrete case:
k
j=0
j=0
s=T ( r k )= ( L1 ) p r ( r j ) =( L1 )
n j ( L1) k
=
n
MN
MN j=0 j
Example
Find the histogram equalization transformation function and the power density
function for a 3-bit image (L=8) of size 64x64 pixels (MN=4096).
rk
nk
pr ( r k ) =nk / MN
r 0=0
790
0.19
r 1=1
1023
0.25
r 2=2
850
0.21
r 3=3
656
0.16
r 4 =4
329
0.08
r 5=5
245
0.06
r 6=6
122
0.03
r 7=7
81
0.02
s 2=5 ,
s 3=6, s4 =6 ,
Figure 4: (a) Original histogram (b) The transformation function (c) Equalized histogram
Histogram Matching
Histogram matching (or Histogram specification) is the transformation of an image
so that its histogram matches a specified histogram.
Let r and z be continuous intensities variables and let p r(r) and pz(z) to be their
corresponding continuous PDF.
Let s be a random variable with the property
s=T ( r )=
This is the expression of continuous histogram equalization.
Then define a random variable z with property
z
G ( z )= ( L1 ) p z ( t ) dt=s
0
Thus
z=G
[ T ( r ) ] =G1 (s )
Those equations above show that an image whose intensity levels have a specified
PDF can be obtained from a given image by using following procedure:
1. Obtain pr(r) from the input image and then obtain the value of s
2. Use the specified PDF to obtain the transformation function G(z)
3. Obtain the inverse transformation
z=G1 ( z)
4. Obtain the output image by first equalizing the input image. For each pixel in
equalized image, perform the inverse mapping
z=G1 ( z)
s k =T ( r k ) =( L1 ) p r ( r j ) =
j=0
L1
n for k =0,1,2, , L1
MN j=0 j
G ( zq )=( L1 ) p z ( z i ) =s k
i=0
zq
z q=G1 ( s k )
Example
Suppose that a 3-bit image (L=8) of size 64 64 pixels (MN = 4096) has the
intensity distribution shown in the following table (on the left). Get the histogram
transformation function and make the output image with the specified histogram,
listed in the table on the right.
s 0=1
s 1=3
s 2=5
s 3=6
s 4 =7
s 5=7
s 7=3
s 0=7
G(z 0)=0.00 0
G(z 1)=0.00 0
G( z 2)=0.00 0
G(z 3)=1.0 5 1
G ( z 4 )=2.45 2
G(z 5)=4.55 5
G( z 6)=5.95 6
G(z 7)=7.00 7
Finally we have the mapping table for pixels from equalized image to
specified image.
sk
1
3
5
6
7
zq
3
4
5
6
7
Matlab implementation
In Matlab, we can use imhistmatch function to adjust histogram of an image to
match with histogram of a reference image.