Mpa 4
Mpa 4
Image Enhancement-
An image whose pixels tend to occupy
the entire range of possible gray levels, in
addition, tend to be distributed uniformly,
will have an appearance of high contrast
and will exhibit a large variety of gray
tones.
Histogram Equalization
Histogram equalization is a way of improving the
local contrast of an image without altering the
global contrast to a significant degree.
◦ This method is especially useful in images having large
regions of similar tone such as an image with a very
light background and dark foreground.
◦ Histogram equalization can expose hidden details in an
image by stretching out the contrast of local regions
and hence making the differences in the region more
pronounced and visible.
◦ Non-linear point processing technique that attempts to
flatten the histogram such that there are equal
numbers of each sample value in the image.
3
Histogram Equalization
s T (r ) 0 r L 1
a. T(r) is a strictly monotonically increasing function
in the interval 0 r L -1;
b. 0 T (r ) L -1 for 0 r L -1.
8/21/2024 4
How to implement histogram equalization?
nk
pr (rk ) 0 rk 1 0 k L 1
n
L: Total number of gray levels
nk: Number of pixels with gray value rk
k
sk T (rk ) pr (rj ) 0 k L 1
j 0
Effect of applying the Histogram Equalization.
0.02
0.018
0.016
0.014
0.012
0.01
0.008
0.006
0.004
0.002
0
0 50 100 150 200 250
0.02
0.018
0.016
0.014
0.012
0.01
0.008
0.006
0.004
0.002
0
0 50 100 150 200 250
Another example highlighting the effectiveness of this technique
0.1
0.08
0.06
0.04
0.02
0
0 50 100 150 200 250
0.1
0.08
0.06
0.04
0.02
0
0 50 100 150 200 250
Histogram Equalization
Continuous case:
r
s T (r ) ( L 1) pr ( w)dw
0
Discrete values:
k
sk T (rk ) ( L 1) pr (rj )
j 0
k nj L 1 k
( L 1) nj k=0,1,..., L-1
j 0 MN MN j 0
8/21/2024 10
Example: Histogram Equalization
Suppose that a 3-bit image (L=8) of size 64 × 64 pixels (MN = 4096) has
the intensity distribution shown in following table.
Get the histogram equalization transformation function and give the p s(sk) for each
s k.
8/21/2024 11
Example: Histogram Equalization
0
s0 T (r0 ) 7 pr (rj ) 7 0.19 1.33 1
j 0
1
s1 T (r1 ) 7 pr (rj ) 7 (0.19 0.25) 3.08 3
j 0
s2 4.55 5 s3 5.67 6
s4 6.23 6 s5 6.65 7
s6 6.86 7 s7 7.00 7
8/21/2024 12
Example: Histogram Equalization
8/21/2024 13
Histogram Specification
(Histogram Matching)
Histogram equalization yields an image whose pixels are (in
theory) uniformly distributed among all gray levels.
Goal
Derive a point operation, H(r), that maps the input image into an output image
that has the user-specified histogram.
For discrete gray levels, we have
k
sk T (rk ) pin (r j ) 0 k L 1
j 0
k
vk G ( z k ) pout ( z j ) sk 0 k L 1
j 0
z = G-1(v=s=T(r))
(1) Equalize input image to get an image with uniform gray values, using the
discrete equation:
k
sk T (rk ) pin (rj ) 0 k L 1
j 0
(2) Based on desired histogram to get an image with uniform gray values,
using the discrete equation:
k
vk G( zk ) pout ( z j ) sk 0 k L 1
j 0
1 1
(3)
z G ( v=s ) z G [T ( r )]
Example:
# pixels
Gray value
It is desired to transform this image into a new image, using a transformation
Z=H(r)= G-1[T(r)], with histogram as specified below:
# pixels
Gray values
The transformation T(r) was obtained earlier (reproduced
below):
G-1(0) = ?
G-1(1/7) = 3/7
G-1(2/7) = 4/7
G-1(3/7) = ?
G-1(4/7) = ?
G-1(5/7) = 5/7
G-1(6/7) = 6/7
G-1(1) = 1
Combining the two transformation T and G-1 , compute z=H(r)= G-1[v=s=T(r)]
Applying the transformation H to the original image yields an image with histogram
as below:
Again, the actual histogram of the output image does not exactly but only
approximately matches with the specified histogram. This is because we are dealing with
discrete histograms.
Original image and its histogram
8/21/2024 26
Example: Histogram Matching
8/21/2024 27
8/21/2024 28
Local Histogram Processing
8/21/2024 29
Local Enhancement
8/21/2024 31
Use of Histogram Statistics for Image Enhancement
m ri p (ri )
1
MN
f ( x, y )
x 0 y 0
i 0
L 1
un (r ) (ri m) n p(ri )
i 0
Variance L 1 M 1 N 1
u2 (r ) (ri
1
m) p(ri ) f ( x, y ) m
2 2 2
i 0
MN x 0 y 0
8/21/2024 33
Using Histogram Statistics for Image
Enhancement
Local variance
L 1
2
sxy (ri msxy ) psxy (ri )
2
i 0
8/21/2024 34
Using Histogram Statistics for Image
Enhancement: Example
8/21/2024 35
Thank You