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 L=16L=16 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 I(x,y)=[0,L1]I(x, y) = [0, L-1], the histogram contains LL entries.

  • Example: For an 8-bit grayscale image, L=28=256L = 2^8 = 256.

  • Entry Definition: Each histogram entry is defined as:
    h(i) = \text{number of pixels with intensity } i \text{ for all } 0 <= i < L
    Example: h(255)=number of pixels with intensity =255h(255) = \text{number of pixels with intensity } = 255

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 ff (with intensities [0,L1][0, L-1]) is a discrete function.

    h(r<em>k)=n</em>kh(r<em>k) = n</em>k

    where r<em>kr<em>k is the kth intensity value and n</em>kn</em>k is the number of pixels in ff with intensity rkr_k.

  • Normalization: Normalizing the histogram is a common practice.

  • Normalization Formula: Divide the components by the total number of pixels in the image.

    p(r<em>k)=n</em>kMN for k=0,1,2,,L1p(r<em>k) = \frac{n</em>k}{MN} \text{ for } k = 0, 1, 2, …, L-1

    where MM and NN are the dimensions of the image.

  • Probability Estimation: p(rk)p(r_k) estimates the probability of occurrence of intensity level rr in an image.

    p(rk)=1\sum p(r_k) = 1

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

  1. Count Pixel Intensities (nkn_k):

    • Find the count of each pixel intensity value.
  2. Normalize Values (PDF):

    • Calculate the Probability Density Function (PDF) by dividing each count by the total number of pixels.

      P<em>k=n</em>ksumP<em>k = \frac{n</em>k}{\text{sum}}

  3. Find Running Sum (CDF):

    • Compute the running sum of the PDF values, resulting in the Cumulative Distribution Function (CDF), denoted as SkS_k.
  4. Scale and Round Off:

    • Multiply the CDF values by the maximum gray level value and round off to the nearest integer.
  5. 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:

    I<em>out(r,c)=I</em>in(r,c)I<em>MINI</em>MAXIMIN(MAXMIN)+MINI<em>{\text{out}}(r, c) = \frac{I</em>{\text{in}}(r, c) - I<em>{\text{MIN}}}{I</em>{\text{MAX}} - I_{\text{MIN}}} \cdot (\text{MAX} - \text{MIN}) + \text{MIN}

    • I(r,c)MAXI(r,c)_{\text{MAX}} is the largest gray level value in the image I(r,c)I(r,c)
    • I(r,c)MINI(r,c)_{\text{MIN}} is the smallest gray level value in I(r,c)I(r,c)
    • MAX\text{MAX} and MIN\text{MIN} 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:

    I<em>out(r,c)=I</em>in(r,c)I<em>MINI</em>MAXIMIN(ShrinkMAXShrinkMIN)+ShrinkMINI<em>{\text{out}}(r, c) = \frac{I</em>{\text{in}}(r, c) - I<em>{\text{MIN}}}{I</em>{\text{MAX}} - I_{\text{MIN}}} \cdot (\text{ShrinkMAX} - \text{ShrinkMIN}) + \text{ShrinkMIN}

    • I(r,c)MAXI(r,c)_{\text{MAX}} is the largest gray level value in the image I(r,c)I(r,c)
    • I(r,c)MINI(r,c)_{\text{MIN}} is the smallest gray level value in I(r,c)I(r,c)
    • ShrinkMAX\text{ShrinkMAX} and ShrinkMIN\text{ShrinkMIN} 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:

    I<em>out(r,c)=I</em>in(r,c)+OFFSETI<em>{\text{out}}(r, c) = I</em>{\text{in}}(r, c) + \text{OFFSET}

    • 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
Histograms are commonly viewed in plots as
  • h(r)=n versus rkh(r) = n \text{ versus } r_k
  • p(r)=n<em>kMN versus r</em>kp(r) = \frac{n<em>k}{MN} \text{ versus } r</em>k