What is a Histogram?
In digital image processing, a histogram is a graphical representation of the tonal distribution in a
digital image. It plots the number of pixels for each tonal value.
For grayscale images: The histogram shows the distribution of pixel intensities, typically
ranging from 0 (black) to 255 (white). The x-axis represents the intensity values, and the y-
axis represents the number of pixels at each intensity.
For color images: Histograms can be created for each color channel (Red, Green, Blue)
separately, or a multi-dimensional histogram can represent the joint distribution of color
values.
Histogram-Based Features
Histograms themselves are not features. However, we can derive various features from the
histogram that provide useful information about the image's characteristics. Here are some key
histogram-based features:
1. Mean (Average Intensity):
o Calculated as the average of all pixel intensity values.
o Represents the overall brightness of the image.
o Formula:
o mean = (1/N) * Σ (i * h(i))
where:
N is the total number of pixels.
i is the intensity value.
h(i) is the number of pixels at intensity i.
2. Median Intensity:
o The middle intensity value when all pixel intensities are sorted.
o More robust to outliers (very bright or very dark pixels) compared to the mean.
3. Mode Intensity:
o The most frequently occurring intensity value (the peak of the histogram).
o Indicates the dominant intensity in the image.
4. Variance (or Standard Deviation):
o Measures the spread or dispersion of intensity values around the mean.
o Indicates the contrast of the image.
o Formula for variance:
o variance = (1/N) * Σ ((i - mean)^2 * h(i))
where:
N is the total number of pixels.
i is the intensity value.
h(i) is the number of pixels at intensity i.
5. Skewness:
o Measures the asymmetry of the histogram.
o Indicates whether the intensity distribution is skewed towards brighter or darker
values.
6. Kurtosis:
o Measures the "peakedness" of the histogram.
o Indicates the concentration of intensity values around the mean.
7. Entropy:
o Measures the randomness or disorder of the intensity distribution.
o High entropy indicates a more uniform distribution of intensities.
o Formula:
o entropy = - Σ (p(i) * log2(p(i)))
where:
p(i) is the probability of intensity i (h(i) / N).
8. Histogram Bins:
o The number of bins used to create the histogram can itself be a feature.
o A higher number of bins provides finer detail but can be more sensitive to noise.
9. Percentiles:
o Specific percentiles of the intensity distribution (e.g., 25th percentile, 75th
percentile) can be used as features.
Applications of Histogram-Based Features
Image Enhancement: Histogram equalization and histogram stretching techniques use
histogram information to improve image contrast.
Image Segmentation: Histograms can help identify thresholds for separating objects from
the background based on intensity differences.
Image Classification: Histogram features can be used as input to machine learning models
for classifying images based on their content.
Content-Based Image Retrieval (CBIR): Histograms can be used to compare images based on
their color or intensity distributions.
Medical Image Analysis: Histograms can help identify abnormalities in medical images based
on the distribution of tissue densities.
Advantages of Histogram-Based Features
Computational Efficiency: Histograms are relatively easy and fast to compute.
Robustness to Rotation and Translation: Histograms are generally invariant to rotation and
translation of objects in the image.
Simplicity: They provide a simple yet effective way to represent the global intensity
distribution of an image.
Limitations
Lack of Spatial Information: Histograms only represent the global distribution of intensities
and do not capture spatial relationships between pixels.
Sensitivity to Illumination Changes: Histograms can be affected by changes in illumination
conditions.