Histogram Matching
In this method of histogram matching, one image is modified in terms of contrast based on the contrast level of another image.
Here, two images are given as 1st is an original image and 2nd that is the reference image.
Now, the contrast of an original image 1 is modified based on the contrast of the 2nd reference image, which is nothing but histogram matching.
The steps of histogram matching are as follows:
- First, create the equalized histogram for both images 1 and 2.
- Then map every pixel in the 1st and 2nd images based on the created equalized histograms to generate histogram mapping rules.
- Finally, modify the pixels of an original image 1 based on reference image 2.
Step 1
1] Equalized Histogram for an original image 1 -
Original image 1 contains the pixels named '0, 1, 2, 3, 5, 6, 7, 8, 9'
Compute the Number of Pixels or intensity for each of the pixels mentioned above that is nothing but the frequency of occurrence in the image1.
Then compute the Cumulative Distribution Function (CDF) to generate an equalized histogram.
All these things are shown below in table and chart format:
Pixels |
Histogram (Number of Pixels) |
Equalized Histogram (CDF) |
0 |
3 |
3 |
1 |
2 |
3 + 2 = 5 |
2 |
7 |
5 + 7 = 12 |
3 |
1 |
12 + 1 = 13 |
5 |
6 |
13 + 6 = 19 |
6 |
12 |
19 + 12 = 31 |
7 |
21 |
31 + 21 = 52 |
8 |
8 |
52 + 8 = 60 |
9 |
4 |
60 + 4 = 64 |
Equalized Histogram for an original image 1:
2] Equalized Histogram for the reference image 2 -
Reference image 2 contains the pixels named '0, 1, 2, 3, 4, 5, 6, 7, 8, 9'
Compute the Number of Pixels or intensity for each of the pixels mentioned above that is nothing but the frequency of occurrence in the image1.
Then compute the Cumulative Distribution Function (CDF) to generate an equalized histogram.
All these things are shown below in table and chart format:
Pixels |
Histogram (Number of Pixels) |
Equalized Histogram (CDF) |
0 |
4 |
4 |
1 |
3 |
4 + 3 = 7 |
2 |
6 |
7 + 6 = 13 |
3 |
3 |
13 + 3 = 16 |
4 |
4 |
16 + 4 = 20 |
5 |
6 |
20 + 6 = 26 |
6 |
11 |
26 + 11 = 37 |
7 |
13 |
37 + 13 = 50 |
8 |
8 |
50 + 8 = 58 |
9 |
6 |
58 + 6 = 64 |
Equalized Histogram for the reference image 2:
Step 2
Histogram Mapping Rules -
Step 3
Based on these rules new resultant image of matching is generated.
- Pixel 0 remains as Pixel 0 no need for mapping.
- Pixel 1 mapped as Pixel 0.
- Pixel 2 remains as Pixel 2 no need for mapping.
- Pixel 3 mapped as Pixel 2.
- Pixel 5 mapped as Pixel 4.
- Pixel 6 mapped as Pixel 5.
- Pixel 7 remains as Pixel 7 no need for mapping.
- Pixel 8 remains as Pixel 8 no need for mapping.
- Pixel 9 remains as Pixel 9 no need for mapping.
Therefore, the new resultant matching image looks as follows: