2011 Field Guide To Image Processing (2012)
2011 Field Guide To Image Processing (2012)
Field Guide to
Image
Processing
Khan M. Iftekharuddin
Abdul A. Awwal
Image
Processing
Khan M. Iftekharuddin
Abdul A. Awwal
Published by
SPIE
P.O. Box 10
Bellingham, Washington 98227-0010 USA
Phone: +1.360.676.3290
Fax: +1.360.647.1445
Email: books@spie.org
Web: http://spie.org
Abdul Awwal
Lawrence Livermore National Laboratory
Table of Contents
Spatial-Domain Filtering 6
Image Transforms 6
Image Scaling and Rotation 7
Point Processing 8
Spatial-Domain Convolution Filters 9
Convolution 10
Linear Filters 11
Gradient Filters 13
Histogram Processing 15
Frequency-Domain Filtering 17
The Fourier Transform 17
Discrete Fourier Transform 18
Properties of the Fourier Transform 19
Convolution and Correlation in the Fourier
Domain 20
More Properties of the Fourier Transform 21
Spectral Density 22
Properties of the Discrete Fourier Transform 23
Discrete Correlation and Convolution 26
Circular Convolution and Zero Padding 27
Matched Filtering 28
Filtering with the Fourier Transform 29
Low-Pass and High-Pass Filtering 30
Sampling 31
Spectrum of a Sampled Signal 32
More Sampling 33
Spectrum of a Finite Periodic Signal 34
Image Restoration 36
Image Restoration 36
Linear Space-Invariant Degradation 37
Discrete Formulation 38
Algebraic Restoration 39
Table of Contents
Motion Blur 40
Inverse Filtering 42
Weiner Least-Squares Filtering 43
Image Morphology 50
Erosion and Dilation 50
Opening and Closing 52
Hit-or-Miss Transform 53
Thinning 54
Skeletonization 55
Gray-Level Morphology 56
Training a Structuring Element 57
Time-Frequency-Domain Processing 58
Wavelet Transform 58
Types of Fourier Transforms 59
Wavelet Basis 60
Continuous Wavelet Transform 61
Wavelet Series Expansion 62
Discrete Wavelet Transform 63
Subband Coding 64
Mirror Filter and Scaling Vector 65
Wavelet Vector and 1D DWT Computation 66
2D Discrete Wavelet Transform 67
Image Compression 69
Data Redundancy 69
Error-Free Compression 70
Spatial Redundancy 71
Differential Encoding Example 72
Block Truncation Coding: Lossy Compression 73
Discrete Cosine Transform 74
JPEG Compression 75
Equation Summary 76
Bibliography 81
Index 82
CΨ Admissibility condition
e p,q ( t) Windowed Fourier transform
f ªs Erosion
f ⊕s Dilation
F Fourier transform operator
f ( k) 1D discrete signal
f ( k) ⊗ g( k) Correlation operation
Fn Fourier series expansion
F ( n) Discrete Fourier transform of 1D signal
F ( u, v) Fourier-transformed image
f ( x) ∗ g ( x) Convolution operation
f ( x, y) Image
fˆ( x, y) Restored (approximate) image
G ( n, m) Discrete Fourier transform of 2D signal
H Degradation model
H −1 Inverse filter
H ( u, v) 2D filter in the frequency domain
h( x, y) 2D filter (transfer function) in the
spatial domain
I Intensity
I∗E Hit-and-miss transform
i ( x, y) Illumination
L Grayscale
m Degraded image
n( x, y) 2D noise in spatial domain
p x,y ( x, y) Probability density function (PDF)
R Regions
rect( x/a) rect function
R f f ( x, y) Autocorrelation
R f g ( x, y) Cross-correlation
r ( x, y) Reflectance
sinc(au) sinc function
T Transformation matrix
W f (a, b) Wavelet transform
δm,n 2D discrete Kronecker delta
δ( t) Delta function
µ Mean
Field Guide to Image Processing
x
σ Standard deviation
Φ( t ) 1D scaling vector
Ψa,b ( x) Wavelet basis function
Ψ( t) 1D wavelet vector
Random Signals
0 ≤ f ( x, y) < ∞
and
f ( x, y) = i ( x, y) r ( x, y) = L ⇒ gray level
0 < i ( x, y) < ∞
and
0 ≤ r ( x, y) < 1
f (0, 0) f (0, 1) ··· f (0, M − 1)
f (1, 0) f (1, 1) ··· f (1, M − 1)
f ( x, y) ≈
···
f ( N − 1, 0) f ( N − 1, 1) · · · f ( N − 1, M − 1) N × M
b = N × M × k = N2k (if N = M )
Image Transforms
X∗ Sx 0 0 0 X
Y ∗ 0 S y 0 0 Y
∗ =
Z 0 0 S z 0 Z
1 0 0 0 1 1
Similarly, an image can be ro-
tated about coordinate axes as
shown. Rotation of an image may
involve:
Image rotation about the Z axis by an angle θ (affects X
and Y coordinates):
cos θ sin θ 0 0
− sin θ cos θ 0 0
Rθ =
0
0 1 0
0 0 0 1
Image rotation about the X axis by an angle α:
1 0 0 0
0 cos α sin α 0
Rα =
0 − sin α cos α 0
0 0 0 1
Image rotation about the Y axis by an angle β:
cos β 0 − sin β 0
0 1 0 0
Rβ =
sin β 0 cos β 0
0 0 0 1
It is possible to have translation, scaling, and rotation
together as v∗ = R [s(Tv)], where the order is important. It
is also possible to have the inverse for all previous 4 × 4
matrices together, with inverse translation matrix T −1
as
1 0 0 −X0
0 1 0 −Y0
T −1 =
0 0 1 − Z0
0 0 0 −1
Point Processing
Convolution
Linear Filters
A simple low-pass
filter (LPF) is a
three-pixel window
with equal weights:
[1/3, 1/3, 1/3]. A sam-
ple LPF is pro-
vided.
A complimentary
high-pass filter (HPF)
is given as
[−1/3, 2/3, −1/3] = [0, 1, 0] − [1/3, 1/3, 1/3]
Some of the properties of LPF and HPF include:
• The sum of the LPF weights is one, and the sum of
the HPF weights is zero.
• The LPF preserves the signal mean, and the HPF
removes the signal mean.
• LP-filtered images obtain the same mean but a
lower standard deviation than the original image
histogram.
Gradient Filters
Gradient filters provide a way to find the image gradient
(derivative) in any direction. These operators are also
called edge detectors since they are good at picking up
edge information in an image.
200
150
100 0
50 10
0 20
10
20 30
30
The gradient,
q
|∆ f | = G 2x + G 2y
Z1 Z2 Z3
Z4 Z5 Z6
Z7 Z8 Z9
Histogram Processing
where f ( x) must be
• continuous in the finite region and
• absolutely integrable.
−1
NX ³ ´
− j 2Nπ nk
F ( n) = fk e , n = 0 , 1, . . . , N − 1
k=0
−1 ³ ´
1 NX j 2Nπ kn
f ( k) = Fn e , k = 0, 1, . . . , N − 1
N n=0
−1 NX
NX −1 ³ ´
− j 2Nπ ( kn+ ml )
G ( n, m) = g k,l e ,
k=0 l =0
m = 0, 1, . . . , M − 1, n = 0, 1, . . . ., N − 1
NX
(
−1 NX −1 ³ ´ ) ³ ´
− j 2Nπ kn − j 2Nπ ml
= g k,l e e ,
k=0 l =0
m = 0, 1, . . . , M − 1, n = 0, 1, . . . ., N − 1
The case when the two functions are the same is termed
autocorrelation; when they are different, it is called
cross-correlation.
reduces to
F { f ( x ) ⊗ f ( x ) } = | F ( u )| 2
Spectral Density
S g g ( u, v) = S f f ( u, v) | H ( u, v)|2
S g g ( u, v) = S f f ( u, v) | H ( u, v)|2 + S nn ( u, v)
−1 NX
NX −1 ³ ´
− j 2Nπ ( kn+ ml )
F ( n, m) = f k,l e ,
k=0 l =0
n = 0, 1, . . . ., N − 1; m = 0, 1, . . . , M − 1
NX
(
−1 NX −1 ³ ´ ) ³ ´
− j 2Nπ kn − j 2Nπ ml
F ( n, m) = f k,l e e ,
l =0 k=0
n = 0, 1, . . . ., N − 1; m = 0, 1, . . . , M − 1
−1
NX ³ ´
− j 2Nπ ml
F ( n, m) = F ( n, l ) e
l =0
where
−1
NX ³ ´
− j 2Nπ kn
F ( n, l ) = f k,l e
k=0
F ( n) = F ( n + N )
f k = f k+ N
F ( n, m) = F ( n + N, m + N )
= F ( n + N, m)
= F ( n, m + N )
1
f (ak, bl ) ⇔ F ( m/a, n/ b)
|a.b|
Modulation:³ When
´ a signal is multiplied by a complex
j 2π
( m 0 k)
exponential e N
, its DFT is shifted by m 0 units:
³ ´
j 2π
( m 0 k+ n 0 l )
f ( k, l ) e N
↔ F (m − m0 , n − n0 )
where m = 0, 1, . . . , M − 1 and n = 0, 1, . . . , N − 1.
Time/space reversal: When the signal is reversed in the
time/space domain, the DFT of the reversed signal is given
by
f (− k, − l ) ↔ F (− m, − n) = F ( M − m, N − n)
Matched Filtering
G ( u, v) = F ( u, v) H ( u, v) Convolution Property
g( x, y) = F −1 {F ( u, v) H ( u, v)}
(a) (b)
(c)
Sampling
More Sampling
Image Restoration
Discrete Formulation
0 0 h(1)
In a circulant matrix, rows are the reverse of the impulse
response, and each row is a shifted version of the row
above.
If f has two elements, then one element can be worked
out by hand to see how the above matrix–vector product
leads to a convolution. When f is 2D, it becomes a huge
matrix that is complicated to visualize. A 2D extension of
a circulant matrix is known as a block circulant matrix.
To avoid circular convolution, the matrix (image) needs to
be zero padded.
The least-squares filter in the Fourier domain assumes a
transformation matrix A such that M = [A] m, and the least
square estimate fˆ is obtained from a restoration filter P
such that
fˆ = [A]−1 [P][A] m
where P is given by
[Sff ][H]∗T
[P] =
([H][Sff ][H]∗T + [Snn ])
which is similar to the Weiner filter for the continuous
domain.
Here, the correlation matrices [Rxy ] = E [XYT ] and the
spectral density [Sxy ] = [A][Rxy ][A]−1 .
Algebraic Restoration
k nk2 = k m − H fˆk2
fˆ = H −1 m
k m − H fˆk2 = k nk2
fˆ = ( H 0 H + γQ 0 Q )−1 H 0 g
Motion Blur
Inverse Filtering
to obtain
· ¸
G ( u, v)
f ( x, y) = F −1
H ( u, v)
1
is known as the inverse filter, since it is expressed
H ( u,v)
as the inverse of the degradation function.
fˆ( x, y) = m( x, y)∗ p( x, y)
H ∗ ( u, v)S f f ( u, v)
P ( u, v) =
S f f ( u, v)| H ( u, v)2 | + S nn ( u, v)
1 | H ( u, v)|2
=
H ( u, v) | H ( u, v)2 | + S nn (u,v)
S f f ( u,v)
Hough Transform
Clustering
Clustering (cont.)
Hit-or-Miss Transform
Thinning
I i = I − (I ∗ E)
1 1
1 1
0 0
where the 1 in the center pixel is the origin. Note that this
is equivalent to h i
1 1
• a hit transform 1 1 ,
where the origin is the lower left pixel; and
h i
0 0
• a miss transform ,
1 1
where the origin is the upper left pixel.
Skeletonization
Gray-Level Morphology
Wavelet Transform
Wavelet Basis
The Haar basis functions are the simplest and have been
in use for more than a hundred years. Haar wavelet
functions have been included as one subset of Daubechies
basis functions. Haar basis functions contain abrupt
changes in signal.
Subband Coding
where
ϕn ( x) = 2 j/2 ϕ(2 j x − k), j = 0, 1, . . . ; k = 0, 1, . . . ; 2 j ≤ n
φ( x, y) = φ( x)φ( y)
Ψ1 ( x, y) = φ( x)Ψ( y)
Ψ2 ( x, y) = Ψ( x)φ( y)
Ψ3 ( x, y) = Ψ( x)Ψ( y)
f 10 ( m, n) = 〈 f ( x, y), φ( x − 2 m, y − 2 n)〉
f 11 ( m, n) = 〈 f ( x, y), Ψ1 ( x − 2 m, y − 2 n)〉
f 12 ( m, n) = 〈 f ( x, y), Ψ2 ( x − 2 m, y − 2 n)〉
f 13 ( m, n) = 〈 f ( x, y), Ψ3 ( x − 2 m, y − 2 n)〉
Data Redundancy
Error-Free Compression
Method:
• The probabilities are arranged according to their
magnitudes.
• The least-probable two are combined.
• The process is continued until there are two
probabilities remaining.
• The most-probable code is assigned a single bit each.
• Working backward from the combined probabilities,
an extra bit is assigned to each of the component
probable codes until all of the codes have been
assigned.
The average length of the Huffman code is L = 0.5 × 1 +
0.2×2+0.13×3+0.07×4+0.06×5+0.04×5 = 2.07 b. Without
compression, these six levels ( q1 – q6 ) will require 3 bits in
binary.
Spatial Redundancy
q
r
A = f¯ − σ
m−q
m−q
r
B = f¯ + σ
q
where
q m
1 X M
1 X
σ= f¯2 − ( f¯)2 , f¯ = f i , f¯2 = f i2
m i=1 m i=1
−1 NX
4 c(u, v) NX −1 (2 m + 1) uπ (2 n + 1)vπ
G ( u, v) = g m,n cos cos
N2 m=0 n=0 2N 2N
m, n = 0, 1, . . . ., N − 1
where
1
c( u, v) = for m = n = 0
2
= 1 for m, n = 1, 2, . . . , N − 1
Inverse DCT:
1
g( m, n) = G (0, 0)
N
−1 NX
1 NX −1 (2 m + 1) uπ (2 n + 1)vπ
+ 3
G ( u, v)cos cos
2 N u=1 v=1 2N 2N
m, n = 0, 1, . . . ., N − 1
JPEG Compression
Equation Summary
Entropy:
∞
X
H=− p k log2 p k bits/message
k=1
Image model:
f ( x, y) = i ( x, y) r ( x, y) = L ⇒ gray level
Equation Summary
2D Fourier transform:
Z ∞ Z ∞
G ( u, v) = g( x, y) e− j2π(ux+v y) dx d y
−∞ −∞
Convolution:
F { f ( x)∗ g( x)} = F ( u)G ( u)
G ( u, v) = F ( u, v) H ( u, v)
Image Restoration
Convolution integral with noise:
Ï
m( x, y) = f (α, β) h( x − α, y − β) d α d β + n( x, y)
−∞
Equation Summary
Weiner Filter:
H ∗ ( u, v)S f f ( u, v)
P ( u, v) =
S f f ( u, v)| H ( u, v)2 | + S nn ( u, v)
Image Morphology
Thinning:
I i = I − (I ∗ E)
Dilation:
( f ⊕ s)( k, l ) = max{ f ( k − m, l − n)
+ s( m, n) | ( k − m)( l − n) ∈ D f ;( m, n) ∈ D s }
Grayscale erosion:
( f ª s)( k, l ) = max{ f ( k + m, l + n) − s(m, n) | ( k + m)( l + n) ∈
D f ;( m, n) ∈ g }
Morphological gradient:
g = ( f ⊕ s) − ( f ª s)
Wavelet Transform
Continuous Fourier transform:
Z ∞
f˜( p, q) = f ( t) g( t − p) e2π jqt dt
−∞
Equation Summary
Fourier spectrum:
|Ψ( s)|2
∞
Z
CΨ = ds < ∞
−∞ s
Wavelet basis functions:
1 x−b
µ ¶
Ψa,b ( x) = p Ψ
a a
Continuous wavelet transform:
Z ∞
W f (a, b) = 〈 f , Ψa,b ( x)〉 = f ( x) Ψa,b ( x) dx
−∞
Orthogonal function:
Ψ j,k ( x) = 2 j/2 Ψ (2 j x − k), for − ∞ < j, k < ∞
〈Ψ j,k , Ψl,m 〉 = δ j,l δk,m
∞ X ∞
c j,k Ψ j,k ( x); where
X
f ( x) =
j =−∞ −∞
Z ∞
c j,k = 〈 f ( x), Ψ j,k ( x)〉 = 2 j/2 f ( x)Ψ(2 j x − k) dx
−∞
Equation Summary
where
ϕn ( x) = 2 j/2 ϕ (2 j x − k); j = 0, 1, . . . .; k = 0, 1, . . . ; 2 j ≤ n
Basic wavelet:
Ψ( t) =
X
g 1 ( k) ϕ(2 t − k)
k
Image Compression
Average bit length:
−1
LX
L avg = l( gk) p ( gk)
k=0
Bibliography
Index
Index
Index
Index
P.O. Box 10
Bellingham, WA 98227-0010
ISBN: 9780819490216
SPIE Vol. No.: FG25
www.spie.org/press/fieldguides