Detailed Notes on Histogram Processing
Histogram Processing
Overview
Histogram Processing: A technique used in digital image processing for manipulating the histogram of an image to enhance its visual quality.
Topics Covered: Histogram equalization, histogram matching, local histogram processing, and using histogram statistics for image enhancement.
Histograms
Definition: A graphical representation of the distribution of pixel intensities in a digital image.
Function: Plots the number of pixels for each intensity value.
Application: Used in digital cameras to avoid over-exposed pictures.
Usage: Photographers use histograms to analyze the distribution of captured intensities.
Histogram Axes
Horizontal Axis: Represents intensity variations (gray levels).
Vertical Axis: Represents the number of pixels for each intensity value.
Intensity Representation
Left Side: Black and dark areas.
Middle: Medium grey color.
Histogram Example
Image: A sample image with 256 distinct gray levels (8 bits).
Histogram: Shows the frequency of each gray level.
Statistical Measures
Count: 1,920,000 pixels.
Mean: 118.848.
Standard Deviation: 59.179.
Minimum: 0.
Maximum: 251.
Mode: 184 (occurs 30,513 times).
Histogram Properties
Statistical Information: Histograms provide statistical information about the image.
Location Insensitivity: Histograms do not indicate the location of pixels with specific intensity values.
Example: In an image with gray levels, 10 pixels have an intensity value of 2.
Identical Histograms
Multiple Images: Different images can have the same histogram.
Example: Images with half of the pixels gray and half white will have the same histogram, regardless of pixel arrangement.
Implication: Same histogram implies same statistics but potentially different intensity distributions.
Histogram Definition
Range: For a grayscale image with intensity values in the range , the histogram contains entries.
Example: For an 8-bit grayscale image, .
Entry Definition: Each histogram entry is defined as:
h(i) = \text{number of pixels with intensity } i \text{ for all } 0 <= i < L
Example:
Image Contrast
Definition: Indicates how easily objects in an image can be distinguished.
High Contrast: Image with many distinct intensity values.
Low Contrast: Image that uses few intensity values.
Histogram and Contrast
Low Contrast Image:Appears dull with most pixels concentrated in a narrow range of gray levels.
Normal Contrast Image:Utilizes a broader range of intensity values.
High Contrast Image: Spreads intensity values across the entire spectrum.
Histogram Analysis
More Black Pixels: Histogram is concentrated on the left side.
More White Pixels: Histogram is concentrated on the right side.
Pixels of All Intensity Levels: Histogram is evenly distributed.
Histogram Processing
Discrete Function: The histogram of a digital image (with intensities ) is a discrete function.
where is the kth intensity value and is the number of pixels in with intensity .
Normalization: Normalizing the histogram is a common practice.
Normalization Formula: Divide the components by the total number of pixels in the image.
where and are the dimensions of the image.
Probability Estimation: estimates the probability of occurrence of intensity level in an image.
Visual Examples of Histograms
Dark Image: Histogram is concentrated on the lower end of the gray scale.
Light Image: Histogram is concentrated on the higher end of the gray scale.
Low-Contrast Image: Histogram is narrow and concentrated.
High-Contrast Image: Histogram covers a broad range of gray levels.
Histogram Equalization
Definition: A process for increasing the contrast in an image by spreading the histogram out to be approximately uniformly distributed.
Effect: Gray levels of an image subjected to histogram equalization are spread out and tend to reach white.
Benefit: Increase of dynamic range produces an increase in contrast.
Drawback: For images with low contrast, histogram equalization can increase visual graininess.
Histogram Equalization Steps
Count Pixel Intensities ():
- Find the count of each pixel intensity value.
Normalize Values (PDF):
Calculate the Probability Density Function (PDF) by dividing each count by the total number of pixels.
Find Running Sum (CDF):
- Compute the running sum of the PDF values, resulting in the Cumulative Distribution Function (CDF), denoted as .
Scale and Round Off:
- Multiply the CDF values by the maximum gray level value and round off to the nearest integer.
Map Gray Levels:
- Map the original gray level values to the results from step (4) using a one-to-one correspondence.
Histogram Modification
Examination of the histogram is one of the most useful tools for image enhancement.
Histogram modification makes it easy to modify images to improve them.
Mapping functions can stretch, shrink (compress), or slide histograms.
Histogram stretching and Histogram shrinking are forms of gray scale modification referred to as histogram scaling.
Histogram Stretch
Mapping Function Equation:
- is the largest gray level value in the image
- is the smallest gray level value in
- and correspond to the maximum and minimum gray level values possible (for an 8-bit image these are 0 and 255).
Effect: This equation stretches the histogram across the entire gray level range, increasing the contrast of a low contrast image.
Clipping: To allow a small percentage of pixel values to be clipped at the low and high end of the range is useful, this involves truncating values at 0 and 255 for an 8-bit image.
Histogram Shrink
Mapping Function Equation:
- is the largest gray level value in the image
- is the smallest gray level value in
- and correspond to the maximum and minimum desired in the compressed histogram.
Effect: Decreases image contrast by compressing the gray levels.
Usefulness: It may not be useful as an image enhancement tool by itself, but it is used in an image sharpening algorithm (unsharp masking) as a part of an enhancement technique.
Histogram Slide
Purpose: Used to make an image either darker or lighter while retaining the relationship between gray level values.
Method: Accomplished by adding or subtracting a fixed number from all gray level values.
Equation:
The OFFSET value is the amount to slide the histogram.
Any values slid past the minimum and maximum values will be clipped to the respective minimum or maximum.
Positive OFFSET: Increases overall brightness.
Negative OFFSET: Creates a darker image.
Histogram Specification/Histogram Matching
Definition: A method to transform the intensity distribution of an image into a desired or a specified histogram.
Main Aim: To improve the visual quality of an image by changing its contrast, brightness, or color.
Special Case: Well-known histogram equalization method is a special case in which the specified histogram is uniformly distributed.
Applications of Histograms
Histograms are used for simple calculations in software and to analyze an image.
Properties of an image can be predicted by the detailed study of the histogram.
Brightness and contrast of the image can be adjusted.
Used for image equalization to produce a high contrast image.
Histograms are used in thresholding as it improves the appearance of the image.
If we have input and output histogram of an image, we can determine which type of transformation is applied in the algorithm.
Histogram-based techniques are a popular tool for real-time image processing.
Uses of Histogram Processing
- Image enhancements
- Image statistics
- Image compression
- Image segmentation
- Simple to calculate and economic hardware implementations
- Popular tool in real-time image processing
- Provides a global description of the appearance of the image and gives useful information for contrast enhancement.
Types of basic image and corresponding histograms
- Dark
- Light
- Low contrast
- High contrast