L1 - Image Enhancement Spatial Histogram Processing
L1 - Image Enhancement Spatial Histogram Processing
Histogram Processing
Some figures are provided by Pearson Education, Digital Image Processing, Gonzalez & Woods, www.ImageProcessingPlace.com
Image Histogram
• Image Histogram
– digital image with gray levels [0, L-1]
p(rk)
rk
Image Histogram
• Histogram can tell you a lot about an image
• Gray level distribution
• It can be modeled by a statistical distribution (red line)
p(rk)= nk/N
rk
Image Histogram
• Gray level distribution helps define intensity
threshold
T(r)
p(rk)= nk/N
rk
Threshold
Image Histogram
• Histograms are not unique. Two images below
give the same image histogram.
• No spatial information is captured
Image Histogram
• Image types
P(rk) P(rk)
rk rk
Image Histogram
• Image types
P(rk) P(rk)
rk rk
Some
Examples
The figure is provided by Pearson Education, Digital Image Processing, Gonzalez & Woods, www.ImageProcessingPlace.com
Contrast Stretching
Low Contrast
L-1 T(r)
P(rk)
s
r
0 r L-1
P(sk)
s
Contrast Compressing
High Contrast
L-1
P(rk) T(r)
r s
0 r L-1
P(sk)
s
Histogram Equalization
• We want an image with equally many pixels at every
gray level, or the output intensity approximately
follows a uniform distribution.
• Example
– https://demonstrations.wolfram.com/HistogramEqualization/
Histogram Equalization
• The weighted cumulative distribution function (CDF) of r is
represented by (in continuous form), (T is the transformation
function)
The figure is provided by Pearson Education, Digital Image Processing, Gonzalez & Woods, www.ImageProcessingPlace.com
The figure is provided by Pearson Education, Digital Image Processing, Gonzalez & Woods, www.ImageProcessingPlace.com
Use T(r) to equalize the histogram
• Assume the input variable r has been
normalized between [0,1]
The figure is provided by Pearson Education, Digital Image Processing, Gonzalez & Woods, www.ImageProcessingPlace.com
sk = T(rk) sk
T
Input image New image
rk
Pr(rk)
Sk*(1/7)
Gray
levels
nk
Image rk
Histogram
Notice, this is not normalized, y axis is nk.
To normalize, let y axis = p(rk)= nk /N
Example
sk
nk
rk rk
stretching compressing
Histogram
Notice, this is not normalized, y axis is nk.
To normalize, let y axis = p(rk)= nk /N
Example
sk
nk nk
rk T(r) sk
The figure is provided by Pearson Education, Digital Image Processing, Gonzalez & Woods, www.ImageProcessingPlace.com
Histogram Equalization
• Can significantly improve image appearance
– Automatic
– users doesn’t have to perform manual windowing or
manual gray level slicing
place result
(x,y) in (x,y)
Result
calculate histogram
using neighborhood of mxm
about (x,y)
Local Histogram
• Apply histogram equalization about a
neighborhood around (x,y)
Input image
The figure is provided by Pearson Education, Digital Image Processing, Gonzalez & Woods, www.ImageProcessingPlace.com
Histogram Specification
• The histogram equalized image of the input image
The figure is provided by Pearson Education, Digital Image Processing, Gonzalez & Woods, www.ImageProcessingPlace.com
Histogram Specification
• Given the specified PDF , compute all values of the
transformation function
The figure is provided by Pearson Education, Digital Image Processing, Gonzalez & Woods, www.ImageProcessingPlace.com
Histogram Specification
• For each value of (rounded to integer), find the
corresponding value of so that (rounded to integer)
is closest to
• Generate the histogram-
specified image by
mapping every equalized
pixel with value to the
corresponding pixel with
value
The figure is provided by Pearson Education, Digital Image Processing, Gonzalez & Woods, www.ImageProcessingPlace.com