Lec004 Enhancement GrayLevelTrans Part-2
Lec004 Enhancement GrayLevelTrans Part-2
Image Enhancement :
Gray-Level Transformations
Part-2
Gray-Level Transformations
●
Histogram processing
– What is a histogram ?
●
Probability theory refresher
– What can it achieve ?
Gray-Level Transformations
●
Histogram processing
– What can it achieve ?
Gray-Level Transformations
●
Histogram processing
– What can it achieve ?
Gray-Level Transformations
●
Histogram processing
– What can it achieve ?
Gray-Level Transformations
●
Histogram processing
– What can it achieve ?
Gray-Level Transformations
●
Histogram processing
– What is a histogram ?
●
Probability theory refresher (very brief)
– Probability mass/density function
– Random variables
– Random experiments
– Sample space, events, probability functions
– Transformation of a random variable
Gray-Level Transformations
●
Random experiment = an experiment whose
outcome isn’t certain
– Flip of a coin
– Throw of a die
●
Sample space = set of all possible outcomes of a
random experiment
– Coin flip : { head, tail }
– Die throw : { 1, 2, 3, 4, 5, 6 }
Gray-Level Transformations
●
Random experiment
– Select a pixel location in an image
●
Sample space
– Set of all pixel locations
{ (1,1), (1,2), … , (1,8),
(2,1), (2,2), … , (2,8),
…
(8,1), (8,2), … , (8,8) }
Gray-Level Transformations
●
Event is a subset of a sample space
– Event of getting a head on a coin toss = { head }
– Event of getting an even number on a die roll = ?
= { 2, 4, 6 }
– Event of getting a pixel in the left half of the image
●
Event space = set of all possible events
Gray-Level Transformations
●
Probability function P(.)
– A probability function on sample space Ω
assigns every event A ⊆ Ω
a number ∈ [0,1] s.t.
● P (Ω) = 1
●
P (A U B) = P (A) + P (B) when A ∩ B = 0
– P(A) is the probability that event A occurs
– Examples
● Probability function for coin toss = ?
p(b)
– Let b = T(a) a
= CDF(r) * 7
Gray-Level Transformations
Gray-Level Transformations
Gray-Level Transformations
●
Why is the output histogram NOT exactly uniform ?
– Because of discretization of space and intensity
– Theoretically
●
Contradicts the assumption of continuous distributions
(i.e., continuous spatial domain, continuous intensities)
●
We used that to derive transformation for histogram equalization
– Practical problem (1 of 2)
●
Imagine 8-bit images → 256 intensities
●
Imagine an input image containing only 100 different intensities
● Uniform histogram must contain some pixels for each intensity
● How can we map 100 values to 256 values ?
– No systematic way to do that !
Gray-Level Transformations
●
Why is the output histogram NOT exactly uniform ?
– Because the set of intensities in digital images is discrete
– Practical problem (2 of 2)
●
Imagine 8-bit images → 256 intensities
●
Imagine an input image containing 256 different intensities and
2560 pixels
●
Uniform histogram must contain an equal number of (10) pixels
for each intensity
●
If some intensity “a” in input image has 20 pixels,
then intensity b=T(a) in output image will have >= 20 pixels
●
How can we decide which 10 of those >=20 pixels should be
assigned intensity “b” ?
– No systematic way to do that !
Gray-Level Transformations
●
Histogram matching
– Sometimes, we don't want to equalize
– But, we want to match the histogram of one image to
another chosen histogram (NOT uniform)
●
e.g., applications in medical imaging
– In that case, CDFa (a) = CDFb (b) implies
b = CDFb-1 (CDFa (a))
Gray-Level Transformations
●
Histogram matching
Gray-Level Transformations
●
Limitations of histogram equalization
– Images has lots of dark pixels or / and lots of bright pixels
– Then the “middle” intensities don't get contrast enhanced
– How can we get better output ? e.g., top right image
???
Hist. Eq.
Gray-Level Transformations
●
Limitations of histogram equalization
– Images has lots of dark pixels or / and lots of bright pixels
– Then the “middle” intensities don't get contrast enhanced
Hist. Eq.
Gray-Level Transformations
●
Adaptive histogram equalization (AHE)
– Localized analysis
– Algorithm:
For each pixel “p”
●
Construct a window of size NxN around the pixel
●
Perform (partial) histogram equalization within that window
(1) Compute histogram within window
(2) Compute CDF within window
(3) Map the intensity of the center pixel “p” based on the CDF
– Window size N is a user-defined parameter
● User-defined parameter is also called “free” parameter
● How to choose N ?
Gray-Level Transformations
●
Adaptive histogram equalization (AHE)
Gray-Level Transformations
●
Adaptive histogram equalization (AHE)
– Variations in local histograms
Gray-Level Transformations
●
Input image Global Hist. Eq.
● On next slide:
AHE with square windows of widths 25, 64, 100, 200
AHE
AHE
●
How to try to get the best of both worlds ?
– We want to enhance texture, without amplifying noise
Gray-Level Transformations
●
Contrast-limited adaptive histogram equalization
(CLAHE)
– Principle: Contrast amplification in the vicinity of a given
pixel value is given by:
●
Slope of the transformation function
= Slope of the CDF
●
But CDF slope depends on histogram (PDF) value
Gray-Level Transformations
●
Contrast-limited adaptive histogram equalization
(CLAHE)
– Limits the amplification by:
(1) Clip the histogram at a predefined value (free parameter)
(2) Redistribute the mass uniformly throughout the range
(3) Then, compute the CDF
AHE
CLAHE Gray-Level Transformations
Gray-Level Transformations
●
(CL)AHE is computationally expensive
– Computes PDF (+ CDF) at window around at every pixel
●
Approximations to (CL)AHE for speedup
(1) Split image into MxM non-overlapping tiles
●
e.g., M = 9
(2) Compute CDF for each tile
(3)Bilinearly interpolate transformation for all pixels based
on distances from tile centers
Gray-Level Transformations
●
Approximations to CLAHE for speedup
(1) Split image into MxM non-overlapping tiles
(2) Compute CDF for each tile
(3)Bilinearly interpolate transformation for all pixels based
on distances from tile centers