Histogram specification allows for better control over image contrast and brightness by matching the histogram of a source image to a desired reference histogram. This technique enhances visual appearance, ensures consistent intensity distribution, and is particularly useful for improving images from different sources.
What is histogram specification?
Key takeaways:
Histogram specification (or histogram matching) is an image processing technique that adjusts the histogram of a source image to match the histogram of a reference image, aiming for a similar intensity distribution.
The steps to implement a histogram are:
Generate and normalize the histograms for both images.
Compute the cumulative distribution functions (CDFs) for the intensity levels.
Use the CDFs to derive equalization levels, which help map pixel values from the source image to the reference histogram.
Understanding essential terms such as probability distribution function (PDF) and cumulative distribution function (CDF) is crucial, as these metrics form the foundation for performing histogram specification effectively.
The process includes separating frequency counts and intensity values from both images, finding corresponding levels, and making adjustments to achieve the desired histogram.
Histogram matching is widely used in various fields, including medical imaging, remote sensing, color correction, image enhancement, and machine learning, highlighting its versatility and importance in image analysis.
Histogram specification, also known as histogram matching, is a technique used in image processing to modify an image’s histogram to resemble another image’s histogram. The main goal is to give the source image a similar histogram shape as the reference image.
Histogram matching
To perform histogram matching, we need to know the number of intensity values and the size of both images.
Before performing histogram matching, it is essential to understand histogram equalization. We will briefly outline the necessary steps before delving into each in detail.
Calculate the
of intensity values (i.e., the number of pixels for each intensity level) to generate histograms for both the source and reference images.frequency Number of pixels against specific intensity value. Normalize both histograms by dividing their frequency counts by the total number of pixels in the image. This normalization results in the PDF of the intensity levels.
Compute the cumulative distribution functions for the normalized intensity values from both histograms. The CDF is the cumulative sum of the PDF values and represents the probability of a pixel having a value less than or equal to a certain intensity.
Multiply all CDF values by the maximum pixel intensity value (e.g., 255 for an 8-bit image) and round each resulting value to the nearest whole number. This value represents the equalization level for each pixel.
Use the source image’s CDF to create new frequency values for mapping.
Map the pixel values of the source image using the equalization levels obtained from the source image’s CDF and the reference image’s histogram. This step transforms the pixel values of the source image to achieve a histogram that closely resembles the reference image.
If anyone is unfamiliar with the technical terms in the steps above, don’t worry; we will revise these concepts first.
Histogram
The histogram below illustrates the distribution of intensity levels of the given image.
Note: Each box in the image represents one pixel.
This histogram represents the frequency of each intensity value in an image. Pixels with intensity value 0 occur 6 times in the image, pixels with value 2 occur 2 times, and so on.
Calculate PDF
To make calculations easier, let’s use a tabular format to represent the data:
rkrepresents the pixel intensity values, ranging from 0 to L−1 for an image with L possible intensity levels.nkindicates the frequency of each corresponding pixel intensity value rk. It counts how many times each pixel intensity appears in the image.p(rk)denotes the probability of occurrence of each pixel intensity value rk. It can be calculated using the formula:
Where M is the number of rows and N is the number of columns.
The total number of pixels in the image is 25 (5*5), so we will divide each nk value by 25 to get the p(rk).
Calculate CDF
To calculate the CDF for each pixel value, we’ll sum the probability of the current pixel value (p(rk)) with the previous CDF value. Mathematically, this can be expressed as:
Where CDF(sk) is the cumulative distribution function value for the pixel value rk, and CDF(sk−1) is the CDF value for the previous pixel value.
The CDF at the last rk should always be equal to 1; if it is not, there must be a mistake in the calculation.
Calculate histogram equalization level
We need to get the CDF values within the range of possible intensity values. We multiply each CDF value with the highest intensity value, L-1, where L represents the number of possible intensity values. Then, we round the result to the nearest whole number.
In this example, the value of L is 8, which includes all the possible pixel intensities from 0 – 7. The value of L-1 will be 7.
Apply mapping
First, separate the equalization level and new nk (frequency counts) values from the source image table from the sk (cumulative distribution function) and equalization level values from the reference image table.
Check the new nk values corresponding to the histogram equalization levels in the source table that equal the histogram equalization levels in the reference table. If there is no exact match in the source image table, find a value greater than the current histogram equalization level in the reference image table but with the minimum difference. Thus, we will assign nk values from the source image table to the pixel intensities in the reference image table.
Note: The values in the tables below do not continue from those used to illustrate the concepts above.
Example
Let’s look at a detailed example of how to perform histogram matching.
Note: To find the total number of pixels in the image, multiply the dimensions, i.e., height * width.
Note: Specified images can have different dimensions than the original image.
Histogram matching is extensively used in image processing and computer vision. It finds applications in medical imaging, remote sensing, color correction, image enhancement, computer graphics, face recognition, art restoration, saturation/exposure adjustment, and optimizing data for machine learning.
Conclusion
Histogram specification is a fundamental technique in image processing that transforms one image’s histogram to closely resemble another’s. One can effectively perform histogram matching by systematically generating and analyzing histograms, normalizing data, and employing cumulative distribution functions. This technique has significant implications across various domains, enhancing image quality and enabling more accurate data representation in visual analytics. Understanding the underlying principles and processes of histogram matching is essential for professionals in fields that leverage image processing technologies.
Quiz
Test your understanding of the histogram matching process by attempting this quiz.
What is the initial step in performing histogram matching?
Creating histograms for the source and reference images.
Normalizing the histograms.
Calculating the cumulative distribution function (CDF).
Applying mapping directly.
Frequently asked questions
Haven’t found what you were looking for? Contact Us
What are the advantages of histogram specification?
What is the difference between histogram equalization and specification?
What does a histogram define?
What is the purpose of histogram matching?
What are two important characteristics of a histogram?
Can the histogram of two images be the same?
Where are histograms used in real life?
Free Resources