Image Enhancement
(Histogram Processing)
1
Histogram Equalization
p(r) Original image p(s)
r
s
0 L-1 0 L-1
p(r) = number of pixel
with intensity, r/total
number of pixels in image
Histogram Equalization
Histogram of image Histogram after equalization
n(r) n(s)
A
1/(L-1)
r
s
0 L-1 0 L-1
Histogram Equalization
3-bit image of size 64x64 has intensity distribution
table
M = 64, N=64, L= 23
r nr c (L-1) x c/MN s ns
0 790
1 1023
2 850
3 656
4 329
5 245
6 122
7 81
Histogram Equalization
3-bit image of size 64x64 has intensity distribution
table
M = 64, N=64, L= 23
r nr c (L-1) x c/MN s ns
0 790 790
1 1023 1813
2 850
3 656
4 329
5 245
6 122
7 81
Histogram Equalization
3-bit image of size 64x64 has intensity distribution
table
M = 64, N=64, L= 23
r nr c (L-1)xc/MN s ns
0 790 790
1 1023 1813
2 850 2663
3 656 3319
4 329 3648
5 245 3893
6 122 4015
7 81 4096
Histogram Equalization
3-bit image of size 64x64 has intensity distribution
table
M = 64, N=64, L= 23
r nr c (L-1) x c/MN s ns
0 790 790 1.35
1 1023 1813
2 850 2663
3 656 3319
4 329 3648
5 245 3893
6 122 4015
7 81 4096
Histogram Equalization
3-bit image of size 64x64 has intensity distribution
table
M = 64, N=64, L= 23
r nr c (L-1) x c/MN s ns
0 790 790 1.35
1 1023 1813 3.09
2 850 2663 4.55
3 656 3319 5.67
4 329 3648 6.23
5 245 3893 6.65
6 122 4015 6.86
7 81 4096 7
Histogram Equalization
3-bit image of size 64x64 has intensity distribution
table
M = 64, N=64, L= 23
r nr c (L-1) x s ns
c/MN
0 790 790 1.35 1
1 1023 1813 3.09 3
2 850 2663 4.55 5
3 656 3319 5.67 6
4 329 3648 6.23 6
5 245 3893 6.65 7
6 122 4015 6.86 7
7 81 4096 7 7
Histogram Equalization
3-bit image of size 64x64 has intensity distribution
table
M = 64, N=64, L= 23
r nr c (L-1) x c/MN s ns
=
(7x c)/(64x64)
0 790 790 1.35 1 790
1 1023 1813 3.09 3 1023
2 850 2663 4.55 5 850
3 656 3319 5.67 6
4 329 3648 6.23 6
5 245 3893 6.65 7
6 122 4015 6.86 7
7 81 4096 7 7
Histogram Equalization
3-bit image of size 64x64 has intensity distribution
table
M = 64, N=64, L= 23
r nr c (L-1) x c/MN s ns
=
(7x c)/(64x64)
0 790 790 1.35 1 790
1 1023 1813 3.09 3 1023
2 850 2663 4.55 5 850
3 656 3319 5.67 6 985
4 329 3648 6.23 6
5 245 3893 6.65 7
6 122 4015 6.86 7
7 81 4096 7 7
Histogram Equalization
3-bit image of size 64x64 has intensity distribution
table
M = 64, N=64, L= 23
r nr c (L-1) x c/MN s ns
=
(7x c)/(64x64)
0 790 790 1.35 1 790
1 1023 1813 3.09 3 1023
2 850 2663 4.55 5 850
3 656 3319 5.67 6 985
4 329 3648 6.23 6
5 245 3893 6.65 7 448
6 122 4015 6.86 7
7 81 4096 7 7
Histogram before and after equalization
r nr s ns
0 790 1 790
1 1023 3 1023
2 850 5 850
3 656 6 985
4 329 6
5 245 7 448
6 122 7
7 81 7
ns
nr
r s
Before equalization After equalization
13
Histogram before and after equalization
r nr s ns
0 790 1 790
1 1023 3 1023
2 850 5 850
3 656 6 985
4 329 6
5 245 7 448
6 122 7
7 81 7
ns
nr
r s
Before equalization After equalization
14
Histogram Equalization
Image matrix of an 3-bit image is given below.
Improve contrast the image using histogram
processing
7564317624
5552137651
3675345556
3776567344
6766766443
𝐴=
6775542012
5656634625
7675132442
5432333220
4556667725
Histogram Equalization
Mapping
Before equalization of After equalization
intensity
7463207613
7564317624 r s 4441027640
5552137651 0 0 2674234446
3675345556 1 0 2776467233
3776567344 2 1 6766766332
6766766443 𝐴=
𝐴= 3 2 6774431001
6775542012
4 3 4646623624
5656634625
5 4 7674021331
7675132442
6 6 4321222110
5432333220
7 7 3446667714
4556667725
r nr s ns
0 2 0 7
1 5 0
2 11 1 11
3 13 2 13
4 13 3 13
5 20 4 20
6 21 6 21
7 15 7 15
Histogram Matching/
Specification
Similar to histogram equalization
Does not try to make the histogram flat
Instead histogram of a specified required shape
is computed
18
Histogram Matching
Given 3-bit image of size 64x64 has intensity
distribution table determine transformation to
match required intensity table
1. Compute histogram of image and equalize it to
generate s from r
Given Required
r nr sr z nz
0 790 0 0
1 1023 1 0
2 850 2 0
3 656 3 614
4 329 4 819
5 245 5 1229
6 122 6 819
7 81 7 614
Histogram Matching
2. Determine histogram equalization, sz
r nr sr z nz cz s'z
= 7cz/4096
0 790 1 0 0 0 0
1 1023 3 1 0 0 0
2 850 5 2 0 0 0
3 656 6 3 614 614 1.05
4 329 6 4 819 1433 2.45
5 245 7 5 1229 2662 4.55
6 122 7 6 819 3482 5.95
7 81 7 7 614 4096 7
Histogram Matching
3. Determine ~sz
r nr sr z nz s’z sz
0 790 1 0 0 0 0
1 1023 3 1 0 0 0
2 850 5 2 0 0 0
3 656 6 3 614 1.05 1
4 329 6 4 819 2.45 2
5 245 7 5 1229 4.55 5
6 122 7 6 819 5.95 6
7 81 7 7 614 7 7
Histogram Matching
• For every value of sr, search closest value of sz
• Choose corresponding value of z
sr to z
r nr sr z nz s’z sz
mapping
sr z
0 790 1 0 0 0 0 1 3
1 1023 3 1 0 0 0 3
2 850 5 2 0 0 0 5
3 656 6 3 614 1.05 1 6
4 329 6 4 819 2.45 2 7
5 245 7 5 1229 4.55 5
6 122 7 6 819 5.95 6
7 81 7 7 614 7 7
Histogram Matching
For every value of s, use the stored value of G(z) in
step 2 to find corresponding value of q so that G(z) is
closest to s
sr to z
r nr sr z nz sz ~sz mapping
s z
0 790 1 0 0 0 0 1 3
1 1023 3 1 0 0 0 3 4
2 850 5 2 0 0 0 5 5
3 656 6 3 614 1.05 1 6 6
4 329 6 4 819 2.45 2 7 7
5 245 7 5 1229 4.55 5
6 122 7 6 819 5.95 6
7 81 7 7 614 7 7
Mapping for Histogram Matching
• For every value of r, select corresponding value of s
• For every value of s select corresponding value of z
r nr s z sr to z
mapping
0 790 1 3
s z
1 1023 3 4
1 3
2 850 5 5
3 656 6 6 3 4
4 329 6 6 5 5
5 245 7 7 6 6
6 122 7 7 7 7
7 81 7 7
r to z mapping
Mapping for Histogram Matching
For each value of z, determine number of pixels
r s z nr nz
0 1 3 790 790
1 3 4 1023 1023
2 5 5 850 850
3 6 6 656 985
4 6 6 329
5 7 7 245 448
6 7 7 122
7 7 7 81
r to z mapping and corresponding number of pixels
Histogram before and after matching
Before equalization After equalization
After matching
26
27
Transfer Function
Histogram of original image
Sometimes
equalization is not
effective
Equalized Image
Histogram of equalized Image
28
Transfer Function Histogram of original image
Sometimes
equalization is not
effective
Equalized Image
Histogram of equalized Image
29
Transfer Function
Sometimes
equalization is not
effective
Equalized Image
Histogram of equalized Image
30
equalized matched
31
Global & Local Enhancement
Sometimes it is necessary to enhance details over small area of
an image
Number of pixels in small area has negligible influence on the
computation for entire image
Therefore, Global histogram processing does not help
Global histogram processing
• intensity distribution of entire image
• Suitable for overall enhancement
• Pixels are modified by a transformation function based on
the gray-level content of an entire image
Local histogram processing
• Transformation function is derived for neighborhood of each
pixel
32
Local Histogram Equalization
Image matrix of an 3-bit image is given below.
Improve contrast the image using histogram
processing
Apply 5x5 histogram equalization
7564317624
5552137651
3675345556 Apply equalization to all 4
3776567344 subparts of image
6766766443 separately
𝐴=
6775542012
5656634625
7675132442
5432333220
4556667725
Local Histogram Equalization
Image matrix of an 3-bit image is given below.
Improve contrast the image using histogram
processing
Apply 5x5 histogram equalization
Subpart 1
Subpart 1 Subpart 2
7564317624 r nr c 7x s
c/25
5552137651
3675345556
3776567344
6766766443
𝐴=
6775542012
5656634625
7675132442
5432333220
4556667725
Subpart 3 Subpart 4
Local Histogram Equalization
Image matrix of an 3-bit image is given below.
Improve contrast the image using histogram
processing
Apply 5x5 histogram equalization
Subpart 1
Subpart 1 Subpart 2
7564317624 r nr c 7x s
c/25
5552137651
0 0 0 0 0
3675345556
3776567344 1 1 1 0.28 0
6766766443 2 1 2 0.56 1
𝐴= 3 4 6 1.68 2
6775542012
5656634625 4 1 7 1.96 2
7675132442 5 6 13 3.64 4
5432333220 6 6 19 5.32 5
4556667725 7 6 25 7 7
Subpart 3 Subpart 4
Local Histogram Equalization
Image matrix of an 3-bit image is given below.
Improve contrast the image using histogram
processing
Apply 5x5 histogram equalization
Subpart 1 Subpart 2 Subpart 1
7564317624 7 4 5 2 2
4 4 4 1 0
5552137651 2 5 7 4 2
3675345556 2 7 7 5 4
= 5 7 5 5 7
3776567344 𝐴𝑒𝑞
6766766443
𝐴=
6775542012
5656634625
7675132442
5432333220
4556667725
Subpart 3 Subpart 4
Local Enhancement
Original Image
37
Local Enhancement
After Global Histogram
Original Image Equalization
38
Local Enhancement
After Global Histogram After Local Histogram
Original Image Equalization Equalization
39