0
2.0kviews
Histogram Matching for 8 * 8 images.

Consider the following two 8 * 8 images. Perform histogram matching for the image on the left using the reference image on the right and plot the histogram of the reference image and the resulting histogram of the matching.

0
146views

## 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 -

• Based on the Equalized histogram values calculated for both the images now, generate the mapping rules for each pixel.
• To do this pixel values of CDF in the reference image 2 that goes near the pixel values of CDF in an original image 1 are picked.

• In Image 1 CDF value of Pixel 0 is 3 which goes near to the CDF value of 4 of Pixel 0 of Image 2.
• In Image 1 CDF value of Pixel 1 is 5 which goes near to the CDF value of 4 of Pixel 0 of Image 2.
• In Image 1 CDF value of Pixel 2 is 12 which goes near to the CDF value of 13 of Pixel 2 of Image 2.
• In Image 1 CDF value of Pixel 3 is 13 which goes near to the CDF value of 13 of Pixel 2 of Image 2.
• In Image 1 CDF value of Pixel 5 is 19 which goes near to the CDF value of 20 of Pixel 4 of Image 2.
• In Image 1 CDF value of Pixel 6 is 31 which goes near to the CDF value of 26 of Pixel 5 of Image 2.
• In Image 1 CDF value of Pixel 7 is 52 which goes near to the CDF value of 50 of Pixel 7 of Image 2.
• In Image 1 CDF value of Pixel 8 is 60 which goes near to the CDF value of 58 of Pixel 8 of Image 2.
• In Image 1 CDF value of Pixel 9 is 64 which goes near to the CDF value of 64 of Pixel 9 of Image 2.
• The rules for histogram mapping are shown below figure:

## 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: