Lect 3
Lect 3
Week-3
1
Point Processing Transformations
There are many different kinds of grey level
transformations
Three of the most
common are shown
here
◼ Linear
⚫ Negative/Identity
◼ Logarithmic
⚫ Log/Inverse log
◼ Power law
2
Point Processing Example:
Negative Images
Reverses the gray level order
For L gray levels, the transformation has the
form:
s = ( L − 1) − r
Negative images are useful for enhancing white or grey detail embedded in
dark regions of an image
3
Point Processing Example:
Negative Images
4
Logarithmic Transformations
The general form of the log transformation is
s = c log(1 + r )
The log transformation maps a narrow range of low input grey level values into
a wider range of output values
The inverse log transformation performs the opposite transformation
5
Logarithmic Transformations
Properties
◼ For lower amplitudes of
input image the range of
gray levels is expanded
◼ For higher amplitudes of
input image the range of
gray levels is compressed
6
Logarithmic Transformations
Application
◼ This transformation is suitable for the case when the
dynamic range of a processed image far exceeds the
capability of the display device (e.g. display of the
Fourier spectrum of an image)
◼ Also called “dynamic-range compression / expansion”
7
Logarithmic Transformations
8
Power Law Transformations
Power law transformations have the following form
s = c r
Map a narrow range
of dark input values
into a wider range of
output values or vice
versa
Varying γ gives a whole
family of curves
9
Power Law Transformations
For < 1: Expands values of dark pixels, compress
values of brighter pixels
For > 1: Compresses values of dark pixels,
expand values of brighter pixels
If =1 & c=1: Identity transformation (s = r)
11
Power Law Transformations
Contrast Enhancement
12
Power Law Transformations
Contrast Enhancement
γ = 0.6
1
Transformed Intensities
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1
Old Intensities
13
Power Law Transformations
Contrast Enhancement
γ = 0.4
1
0.9
Transformed Intensities
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1
Original Intensities
14
Power Law Transformations
Contrast Enhancement
γ = 0.3
1
0.9
Transformed Intensities
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1
Original Intensities
15
Power Law Transformations
Contrast Enhancement
17
Power Law Transformations
Contrast Enhancement
18
Image Enhancement
Aerial Result of
Power law
Image
transformation
c = 1, = 3.0
(suitable)
Result of
Power law
Result of transformation
Power law c = 1, = 5.0
transformation (high contrast,
c = 1, = 4.0 some regions are
(suitable) too dark)
19
Histogram of a Grayscale Image
20
HISTOGRAM
• A discrete function h(rk)=nk
– rk is the kth gray level
– nk is the number of pixels having gray level rk in the
image
• Ex:
nk
6
5
0 1 2 3 4
1 3 3 0 3
0 1 3 0 2
1
3 0 3 1 rk
0 1 2 3
21
UNIQUENESS
22
Histogram of a Grayscale Image
23
Histogram of a Grayscale Image
Black marks
pixels with
intensity g
Plot of histogram:
number of pixels with intensity g
24
Histogram of a Grayscale Image
Black marks
pixels with
intensity g
Plot of histogram:
number of pixels with intensity g
25
Histogram of a Grayscale Image
hI ( g ) = the number
of pixels in I
with graylevel g.
26
Histogram of a Color Image
If I is a 3-band image
then I(r,c,b) is an integer between 0 and 255.
I has 3 histograms:
◼ hR(g) = # of pixels in I(:,:,1) with intensity value g
◼ hG(g) = # of pixels in I(:,:,2) with intensity value g
◼ hB(g) = # of pixels in I(:,:,3) with intensity value g
27
Histogram of a Color Image
28
Histogram: Example
Dark Image
Bright Image
29
Histogram: Example
Dark image
Components of
histogram are
concentrated on
the low side of
the gray scale
Bright image
Components of
histogram are
concentrated on
the high side of
the gray scale
30
HISTOGRAM INSIGHT INTO CONTRAST
31
Histogram: Example
32
Histogram: Example
34
Contrast Stretching
255
L
L −1
s = T (r ) = (r − rmin )
−
127
max min
r r
0
0 rmin 127 rmax255
35
Contrast Stretching
36
Histogram Equalization
37
HISTOGRAM EQUALIZATION
38
AERIAL PHOTOGRAPH OF THE PENTAGON
40
The Probability Distribution Function
of an Image
41
The Cumulative Distribution Function
of an Image
Let q = I(r,c) be the value of a randomly
selected pixel from I. Let g be a specific gray
level. The probability that q ≤ g is given by
g
1 g
h ( )
I
PI ( g ) = pI ( ) = hI ( ) = =0
255
,
h ( )
=0 A =0
I
=0
where hI(γ ) is
the histogram of This is the probability that
image I. any given pixel from I has
value less than or equal to g.
42
The Cumulative Distribution Function
of an Image
Let q = I(r,c) be the value of a randomly
selected pixel from I. Let g be a specific gray Also called CDF
level. The probability that q ≤ g is given by for “Cumulative
Distribution
Function”.
g
g
1 g
h ( )
I
PI ( g ) = pI ( ) = hI ( ) = =0
255
,
h ( )
=0 A =0
I
=0
where hI(γ ) is
the histogram of This is the probability that
image I. any given pixel from I has
value less than or equal to g.
43
The Cumulative Distribution Function
of an Image
• P(g) is the fraction of pixels in an image that have intensity
values less than or equal to g.
• P(g) is the probability that a pixel randomly selected from
the given band has an intensity value less than or equal to
g.
• P(g) is the cumulative (or running) sum of p(g) from 0
through g inclusive.
• P(0) = p(0) and P(255) = 1;
44
Histogram Equalization
Let PI ( )
be the cumulative (probability) distribution function of I.
45
Histogram Equalization
The CDF (cumulative
distribution) is the
pdf
LUT for remapping.
CDF
46
Histogram Equalization
The CDF (cumulative
distribution) is the
pdf
LUT for remapping.
LUT
47
Histogram Equalization
The CDF (cumulative
distribution) is the
pdf
LUT for remapping.
LUT
48
Histogram Equalization
49
Histogram Equalization
Luminosity
before
J ( r , c ) = 255 PI I ( r , c ) .
after
50
HISTOGRAM EQUALIZATION
IMPLEMENTATION
0 0 0 0 0
1 1 1 1 4
4 5 6 6 6
8 8 8 8 9
51
HISTOGRAM EQUALIZATION
IMPLEMENTATION
0 0 0 0 0 2 2 2 2 2
1 1 1 1 4 4 4 4 4 5
4 5 6 6 6 5 5 7 7 7
8 8 8 8 9 9 9 9 9 9
Gray levels 0 1 2 3 4 5 6 7 8 9
Counts (h(rk)) 5 4 0 0 2 1 3 0 4 1
r0 r1 r2 r3 r4 r5 r6
sk =round(9•F(rk)) 2 4 5 5 7 9 9
s0 s1 s2 s3 s4 s5 s6
52
Histogram Equalization: Example
Equalized Histogram
54
Histogram Equalization: Example
Equalized Histogram
Low contrast
High Contrast
Equalized Histogram
55
HISTOGRAM MATCHING
(SPECIFICATION)
• HISTOGRAM EQUALIZATION DOES NOT ALLOW
INTERACTIVE IMAGE ENHANCEMENT AND
GENERATES ONLY ONE RESULT: AN
APPROXIMATION TO A UNIFORM HISTOGRAM.
• SOMETIMES THOUGH, WE NEED TO BE ABLE TO
SPECIFY PARTICULAR HISTOGRAM SHAPES
CAPABLE OF HIGHLIGHTING CERTAIN GRAY-LEVEL
RANGES.
56
MAPPINGS
57
HISTOGRAM SPECIFICATION
58
HISTOGRAM SPECIFICATION
k nk pr(rk) sk pz(zk) vk nk
0 790 0.19 0.19 0 0 0
1 1023 0.25 0.44 0 0 0
2 850 0.21 0.65 0 0 0
3 656 0.16 0.81 0.15 0.15 790
4 329 0.08 0.89 0.2 0.35 1023
5 245 0.06 0.95 0.3 0.65 850
6 122 0.03 0.98 0.2 0.85 985
7 81 0.02 1.0 0.15 1.0 448
60
GLOBAL/LOCAL HISTOGRAM EQUALIZATION
61
USE OF HISTOGRAM STATISTICS FOR IMAGE
ENHANCEMENT (Global)
• LET r REPRESENT A GRAY LEVEL IN THE IMAGE [0, L-1], AND LET p(ri )
DENOTE THE NORMALIZED HISTOGRAM COMPONENT
CORRESPONDING TO THE ith VALUE OF r.
• THE nth MOMENT OF r ABOUT ITS MEAN IS DEFINED AS
L −1 n
n (r ) = (ri − m ) p(ri )
i =0
• WHERE m IS THE MEAN VALUE OF r (AVERAGE GRAY LEVEL)
m = i =0 ri p(ri )
L −1
62
USE OF HISTOGRAM STATISTICS FOR IMAGE
ENHANCEMENT (Global)
• THE SECOND MOMENT IS GIVEN BY
L −1 2
2 (r ) = (ri − m ) p(ri )
i =0
63
USE OF HISTOGRAM STATISTICS FOR IMAGE
ENHANCEMENT (Local)
• LET (x,y) BE THE COORDINATES OF A PIXEL IN AN
IMAGE, AND LET SX,Y DENOTE A NEIGBORHOOD OF
SPECIFIED SIZE, CENTERED AT (x,y)
• THE MEAN VALUE mSXY OF THE PIXELS IN SX,Y IS
ms xy = r s ,t p(rs ,t )
( s ,t
) S xy
• THE GRAY LEVEL VARIANCE OF THE PIXELS IN
REGION SX,Y IS GIVEN BY
S xy
2
= r s ,t
− msxy p(rs ,t )
2
( )
s ,t S xy
64
USE OF HISTOGRAM STATISTICS FOR IMAGE
ENHANCEMENT
• THE GLOBAL MEAN AND VARIANCE ARE MEASURED
OVER AN ENTIRE IMAGE AND ARE USEFUL FOR
GROSS ADJUSTMENTS OF OVERALL INTENSITY AND
CONTRAST.
• A USE OF THESE MEASURES IN LOCAL
ENHANCEMENT IS, WHERE THE LOCAL MEAN AND
VARIANCE ARE USED AS THE BASIS FOR MAKING
CHANGES THAT DEPEND ON IMAGE
CHARACTERISTICS IN A PREDEFINED REGION ABOUT
EACH PIXEL IN THE IMAGE.
65
TUNGSTEN FILAMENT IMAGE
66
USE OF HISTOGRAM STATISTICS FOR IMAGE ENHANCEMENT
67
IMAGE ENHANCEMENT IN THE
SPATIAL DOMAIN
68
IMAGE ENHANCEMENT IN THE
SPATIAL DOMAIN
69
Spatial Filtering
70
Spatial Filtering
71
Spatial Filtering
Spatial Filtering: Basics
The output intensity value at (x,y) depends not only on the input
intensity value at (x,y) but also on the specified number of
neighboring intensity values around (x,y)
Spatial masks (also called window, filter, kernel, template) are used
and convolved over the entire image for local enhancement (spatial
filtering)
73
Spatial Filtering: Basics
a b
g ( x, y ) = w(s, t ) f ( x + s, y + t )
s =− a t =− b
m −1 n −1
where a = , b=
2 2
x = 0,1, 2,...., M − 1, y = 0,1, 2,..., N − 1
74
Spatial Filtering: Basics
Given the 3×3 mask with coefficients: w1, w2,…, w9
The mask cover the pixels with gray levels: z1, z2,…, z9
w1 w2 w3 z1 z2 z3
w4 w5 w6 z4 z5 z6
w7 w8 w9 z7 z8 z9
9
z ⎯
⎯ z1w1 + z2 w2 + z3 w3 + + z9 w9 = zi wi
i =1
z gives the output intensity value for the processed image (to be
stored in a new array) at the location of z5 in the input image
75
Spatial Filtering: Basics
Origin x
Neighbourhood
operations: Operate on a
larger neighbourhood of
pixels than point
operations (x, y)
Neighbourhood
78
Spatial Filtering: Basics
Origin x
a b c r s t
d
g
e
h
f
i
* u
x
v
y
w
z
Original Image Filter
Simple 3*3 Pixels
e 3*3 Filter
Neighbourhood
eprocessed = v*e +
r*a + s*b + t*c +
u*d + w*f +
y Image f (x, y) x*g + y*h + z*i
The above is repeated for every pixel in the original image to generate the filtered image
79
Spatial Filtering: Basics
Original Image x Enhanced Image x
123 127 128 119 115 130
y y
80
Spatial Filtering: Basics
Mask operation near the image border: Problem arises when
part of the mask is located outside the image plane
81
Spatial Filtering: Basics
Mask operation near the border: Pixel
replication
83
Spatial Filtering: Basics
Original Image
84
Spatial Filtering: Basics
85
Spatial Filtering: Basics
86
Spatial Filtering: Basics
87
Spatial Filtering: Basics
88
Spatial Filtering: Basics
89
Readings from Book (4th Edn.)
• Chapter – 3
– 3.3
Acknowledgements
Statistical Pattern Recognition: A Review – A.K Jain et al., PAMI (22) 2000
Pattern Recognition and Analysis Course – A.K. Jain, MSU
Material in these slides has been taken from, the following resources
91