Image Contrast & Histograms
Lecture 3
EEE429-Image and Video Communications / EME408-Image Processing
and Vision
Nuwan Vithanage
Image Brightness
• Brightness of a grayscale image is the average intensity of all pixels in
image
Detecting Bad Exposure using Histograms
• Exposure? Are intensity values spread (good) out or bunched up
(bad)
Image Contrast
• The contrast of a grayscale image indicates how easily objects in the
image can be distinguished
• High contrast image: many distinct intensity values
• Low contrast: image uses few intensity values
• Good Contrast? Widely spread intensity values + large difference
between min and max intensity values
Contrast Equation?
• Many different equations for contrast exist
• Examples:
• Michalson’s equation for contrast
• These equations work well for simple images with 2 luminances (i.e.
uniform foreground and background)
• Does not work well for complex scenes with many luminances or if
min and max intensities are small
Histograms and Dynamic Range
• Dynamic Range: Number of distinct pixels in image
• Difficult to increase image dynamic range (e.g. interpolation)
• HDR (12‐14 bits) capture typical, then down‐sample
High Dynamic Range Imaging
• High dynamic range means very bright and very dark parts in a single
image (many distinct values)
• Dynamic range in photographed scene may exceed number of
available bits to represent pixels
• Solution:
• Capture multiple images at different exposures
• Combine them using image processing
Detecting Image Defects using Histograms
• No “best” histogram shape, depends on application
• Image defects
• Saturation: scene illumination values outside the sensor’s range are set to its
min or max values => results in spike at ends of histogram
• Spikes and Gaps in manipulated images (not original). Why?
Image Defects: Effect of Image Compression
• Histograms show impact of image compression
• Example: in GIF compression, dynamic range is reduced to only few
intensities (quantization)
Effect of Image Compression
• Example: Effect of JPEG compression on line graphics JPEG
compression designed for color images
Computing Histograms
Large Histograms: Binning
• High resolution image can yield very large histogram
• Example: 32‐bit image = 232 = 4,294,967,296 columns
• Such a large histogram impractical to display
• Solution? Binning!
• Combine ranges of intensity values into histogram columns
Calculating Bin Size
• Typically use equal sized bins
• Bin size?
• Example: To create 256 bins from 14‐bit image
Binned Histogram
• To calculate which bin a pixel’s intensity belong to
• Previous example. B=256, K = 214 = 16384
Color Image Histograms
• Two types:
1. Intensity histogram:
• Convert color image to gray scale
• Display histogram of gray scale
2. Individual Color Channel Histograms:
• 3 histograms (R,G,B)
Color Image Histograms
• Both types of histograms provide useful information about lighting,
contrast, dynamic range and saturation effects
• No information about the actual color distribution!
• Images with totally different RGB colors can have same R, G and B
histograms
• Solution to this ambiguity is the Combined Color Histogram.
• More on this later
Cumulative Histogram
• Useful for certain operations (e.g. histogram equalization) later
• Analogous to the Cumulative Density Function (CDF)
• Definition:
• Recursive definition
• Monotonically increasing
Cumulative Histogram
Point Operations
• Point operations changes a pixel’s intensity value according to some
function (don’t care about pixel’s neighbor)
• Also called a homogeneous operation
• New pixel intensity depends on
• Pixel’s previous intensity I(u,v)
• Mapping function f( )
• Does not depend on
• Pixel’s location (u,v)
• Intensities of neighboring pixels
Some Homogeneous Point Operations
• Addition (Changes brightness)
• Multiplication (Stretches/shrinks image contrast range)
• Real‐valued functions
• Quantizing pixel values
• Global thresholding
• Gamma correction
Non‐Homogeneous Point Operation
• New pixel value depends on:
• Old value + pixel’s location (u,v)
Clamping
• Deals with pixel values outside displayable range
• Function below will clamp (force) all values to fall within range [a,b]
Example: Modify Intensity and Clamp
• Point operation: increase image contrast by 50% then clamp values
above 255
Inverting Images
• 2 steps
1. Multiple intensity by ‐1
2. Add constant (e.g. amax) to put
result in range [0, amax]
Image Negatives (Inverted Images)
• Image negatives useful for enhancing white or grey detail embedded
in dark regions of an image
• Note how much clearer the tissue is in the negative image of the
mammogram below
Thresholding
• Input values below threshold ath set to a0
• Input values above threshold ath set to a1
• Converts grayscale image to binary image (Binarization) if
• a0 =0
• a1 =1
Thresholding Example
Thresholding and Histograms
• Example with ath = 128
• Thresholding splits histogram, merges halves into a0 , a1
Basic Grey Level Transformations
• 3 most common gray level transformation:
• Linear
• Negative/Identity
• Logarithmic
• Log/Inverse log
• Power law
• nth power/ nth root
Logarithmic Transformations
• Maps narrow range of input levels => wider range of output values
• Inverse log transformation does opposite transformation
• The general form of the log transformation is
• Log transformation of Fourier transform shows more detail
Power Law Transformations
• Power law transformations have the
form
• Map narrow range of dark input values
into wider range of output values or vice
versa
• Varying γ gives a whole family of curves
Power Law Example
• Magnetic Resonance (MR)
image of fractured human
spine
• Different power values
highlight different details
Intensity Windowing
• A clamp operation, then linearly stretching image intensities to fill
possible range
• To window an image in [a,b] with max intensity M
Intensity Windowing Example
Summary
• We have looked at:
• What is a histogram?
• How to create color image histogram?
• Point Operations
• Next time we will continue talk more about Point Operations &
Histogram Equalization