Module II
Module II
Module II
Histogram Modification
d) Histogram of image (c) e) Image after histogram stretching with f) Histogram of image (e)
clipping 1% of the values at the high
and low ends
Histogram shrink
The mapping function equation is as follows:
Number of Pixels
Gray Level Value (Histogram values)
0 10
1 8
2 9
3 2
4 14
5 1
6 5
7 2
1) Create a running sum of the histogram values.
This means the first value is 10, the second is
10+8=18, next 10+8+9=27, and so on. Here we
get 10, 18, 27, 29, 43, 44, 49, 51
2) Normalize by dividing by the total number of
pixels. The total number of pixels is:
10+8+9+2+14+1+5+0 = 51 (note this is the last
number from step 1), so we get: 10/51, 18/51,
27/51, 29/51, 43/51, 44/51, 49/51, 51/51
3) Multiply these values by the maximum gray
level values, in this case 7, and then round the
result to the closest integer. After this is done we
obtain: 1, 2, 4, 4, 6, 6, 7, 7
4) Map the original values to the results from step
3 by a one-to-one correspondence. This is done
as follows:
1.
b
• Histogram specification consists of following 5
steps:
Number of pixels
Gray Level Value in desired histogram
0 1
1 5
2 10
3 15
4 20
5 0
6 0
7 0
2) For this we will use the image and mapping table from
the previous example, where the histogram equalization
mapping table (Mapping Table 1) is given by:
0 1
1 2
2 4
3 4
4 6
5 6
6 7
7 7
3) Find the histogram equalization mapping table
(Mapping Table 2) for the specified histogram:
O H HS OS M
0 1 0 0 1
1 2 1 1 2
2 4 2 2 3
3 4 4 3 3
4 6 7 4 4
5 6 7 5 4
6 7 7 6 4
7 7 7 7 4
5) Use the table from STEP 4 to perform the histogram
specification mapping. For this all we need are columns
O (or OS) and M:
O M
0 1
1 2
2 3
3 3
4 4
5 4
6 4
7 4
Now, all the 0’s get mapped to 1’s, the 1’s to 2’s, the 3’s
to 3’s and so on
• In practice, the desired histogram is often
specified by a continuous (possibly non-linear)
function, for example a sine or a log function.
Original
image
Histogram
of
original
image
Histogram Specification Examples (contd)
Original histogram
Original histogram
SPATIAL AVERAGING
Image Averaging
• A noisy image:
g ( x, y ) f ( x, y ) n ( x, y )
a) Image with added salt-and-pepper noise, b) After median filtering with a 3x3
the probability for salt = probability window,all the noise is not removed
for pepper = 0.10
Median Filter
Note: In this case the red band gives the best results
This will depend on the image and the desired result
Typically the most important color band is
selected, and this choice is very much
application-specific and will not always provide
us with the desired result