View
12
Download
0
Category
Preview:
Citation preview
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 1
Image Enhancement
Intensity Transformation
(x,y)
k
kT
f(x,y) g(x,y)
mask
g(x,y) = T[f(x,y)]
Point Processing (K=1)
Log Transformations
e.g. g(x,y) = c log( 1 + | f(x,y)| )
f(x,y)
g(x,y)
Power-Law Transformations
crs
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 2
Piecewise-Linear Transformation Functions low-contrast images result from poor illumination, lack of dynamic range in the maging sensor, wrong setting of a lens aperture, etc.
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 3
Bit-Plane Slicing
7 6 5 4 3 2 1 0
1 byte
Bit-plane 7(most significant)
Bit-plane 0(least significant)
One 8-bit byte
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 4
Histogram Processing
intensity
count
.. .................
position
intensity
Dark Image Bright Image Low-contrast Image High-contrast Image
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 5
Histogram Equalization Pr(r)
r
Ps(s)
s
T
r
s
rmaxrmin rmaxrmin
Two conditions for T:
(1) T(r) is single-valued and monotonically increasing. (2) r T r r for r r rmin max min max ( )
dr
ds
r
s
Pr(r)
r
ds
s
Ps(s
)
dr
Pr(r) dr = Ps(s) dss = T(r)
dT(r)/dr = ds/dr = Pr(r)/Ps(s)
If Ps(s) = constant = K = 1/( rmax - rmin )
T(r) = Pr(r) dr + rmin
r1K rmin
for rmin r rmax.
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 6
Histogram Matching (Specification)
T1
r
s
Pr(r)
rrmaxrmin
Ps(s)
srmaxrmin
T2
Pq(q)
qrmaxrmin
q
s
T1 T2-1
q = T2 (T1(r))-1
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 7
Use of Histogram Statistics
Let Sxy denote a neighborhood centered at (x, y), xySp be the histogram
of the pixels in Sxy, and L be the number of possible intensity values in the image.
1
0
)(L
iiSiS rprm
xyxy
1
0
22 )()(L
iiSSiS rpmr
xyxyxy
otherwise y)f(x,
DKDk AND ),(),( G2SG10 xy
GS MkmifyxfEyxg xy
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 8
Spatial-Domain Filtering
Correlation w(x,y)☆f(x,y) =
a
as
b
bt
t)ys,t)f(xw(s,
Convolution w(x,y)★f(x,y) =
a
as
b
bt
t)-ys,t)f(xw(s,
Linear Filter
R = gij f(x+i,y+j)i = -m j = -n
nm
g(x)
G(f)
lowpass highpass bandpass Nonlinear Filter
e.g. min filter, max filter, median filter
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 9
Smoothing
smoothing
Purpose: blurring & noise reduction
lowpass spatial filter
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 10
Order-Statistics Filters -- median filter ( nonlinear filter )
The median of a set A is the value M, M A, s.t.
Pr ( {x | x M, x A } ) = Pr ( { x | x M, x A } ).
e.g. the median of { 10, 20, 20, 20, 15, 20, 20, 25, 100 } is 20.
Remarks: 1. Given N samples x1, x2, …, xN,
the sample mean, x , minimizes
N
iixG
1
2)( ;
the sample median, x~ , minimizes
N
iixG
1
)(
2. The sample mean is the maximum likelihood (ML) estimator of location of a constant parameter in Gaussian noise. The sample median is the maximum likelihood (ML) estimator of location of a constant parameter in Laplacian noise.
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 11
Sharpening Purpose: highlight or enhance fine detail.
1st-order derivative
)()1( xfxfx
f
2nd-order derivative
)(2)1()1(2
2
xfxfxfx
f
First Derivatives (Gradient)
gradient of f at (x,y): f f x
f y
T[ , ]
gradient magnitude:
y
f
x
f
y
f
x
f
22 )()(
1 0
- 10
1
- 1 0
0
Roberts Prewitt Sobel
0 0 0
1 2 1
-1 -2 -1 -1 -1 -1
0 0 0
1 1 1
-1
1 0
0
0
-1
-1
1
1
-2
1 0
0
0
-1
-1
2
1
2nd-order Derivatives
-- Laplacian Filter
2
2
2
22
y
f
x
ff
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 12
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 13
--- Unsharp Masking & High-Boost Filtering
),(),(),( yxfyxfyxgmask
),( yxf : a blurred version of f(x,y)
),(),(),( yxgkyxfyxg mask
k = 1 : Unsharp Masking k > 1: High-Boost Filtering
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 14
Combining Spatial Enhancement Methods
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 15
Frequency-Domain Filtering
x
y
u
v
-1
spatial domain frequency domain Frequency-domain methods
Principles of Frequency-Domain Analysis Linear, Shift-Invariant System
linear: T[a x1(t) + b x2(t)] = a T[x1(t)] + b T[x2(t)]
shift-invariant: if y(t) = T[x(t)], then y(t-t0) = T[x(t-t0)]
1-D Convolution
f(x) g(x) = f( )g(x - )d ( Continuous Case )
f(x) g(x) = f m g x m ( Discrete Case )
-
( ) ( )m
T
h(t)
x(t) y(t) = h( )x(t - )d-
1-D Fourier Transform
xX
A
f(x)
0
-2/X - 1/X 0 1/X 2/X
AX
F u( )
u
1
Fourier Transform Pair
{ }
{ }
( ) ( )
( )
( ) ( )
( )
( )
( )
( )
f x F(u) = f x dx
F(u) f(x) = F(u) du
F u R(u) + iI(u) = F(u)
F(u) = R u I u Fourier Spectrum
(u) = tan Phase Angle
P(u) =
-
-
-1 I u
R u
e
e
e
i ux
i ux
i u
2
1 2
2 2
F(u) Power Spectrum2
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 16
1-D Convolution Theorem
f(x) g(x) F(u)G(u) f(x) g(x) F(u) G(u)
Sampling
Whittaker-Shannon Sampling Theorem
x
f(x)
F(u)
u
x
f(x)
......
x
f(x) s(x)s(x)
S(u)F(u) S(u)
F(u)
x
x x
x 1/2w
Reconstruction
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 17
2-D Fourier Transform
Fourier Transform Pair
{ }
{ }
{ }
( ) ( , )
( ) ( , )
( )
(
( )
( )
( , )
f x,y F(u,v) = f x y dxdy
F(u,v) f(x,y) = F(u, v) dudv
Note: F x,y f x y
F u, v R(u, v) + iI(u,v) = F(u,v)
F(u, v) = R
=
=
=
e
e
e
i ux vy
i ux vy
i u v
2
1 2
u, v I u,v Fourier Spectrum
(u, v) = tan Phase Angle
P(u, v) = F(u,v) Power Spectrum
-1 I u, v
R u, v
) ( )
( )( )
( )
2 2
2
2-D Convolution & Convolution Theorem
f(x, y) g(x, y) = f( , )g(x - , y - )d d
f(x, y) g(x, y) = f m, n g x m,y - n n=-m
( ) ( )
*
(x,y)
G(u,v) = H(u,v) F(u,v) g(x,y) = h(x,y) f(x,y) *
optical transfer function point spread function (spatial convolution mask)
H(u,v)
h(x,y) f(x,y) g(x,y)
F(u,v) G(u,v)
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 18
2-D Sampling
2Wu
2Wv u
v
u
1/y
1/xv
2-D sampling function
y
x
y
x
z
Finite Sampling
x
f(x) s(x)
x
h(x)
X
u
F(u) S(u) H(u)
u
x
f(x) s(x) h(x)
X
u u
x
(DFT)
1/x
F(u) S(u) H(u)
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 19
1-D Discrete Fourier Transform (DFT)
f(4)
f(3)
f(2) f(1) f(0)
x0 x1 x2 x3 x4
x
F(4) F(3) F(2) F(1)
F(0)
u0 u1 u2 u3 u4
u
u = 1/ (Nx)
f(x) = F(u)
x =
i2 ux
N
u=0
N-1
0, 1, 2, .. , N - 1
e
F(u) = 1
Nf(x)
u =
-i2 ux
N
x=0
N-1
0, 1, 2, .. , N - 1
e
2-D DFT pair:
F(u,v) = 1
Nf(x,y)
f(x,y) = 1
NF(u,v)
-i2 (ux+vy
N
y=0
N-1
x=0
N-1
i2 (ux+vy
N
v=0
N-1
u=0
N-1
e
e
)
)
F(u,v) = 1
MNf(x,y)
f(x,y) = F(u,v)
-i2 (ux
M
vy
N
y=0
N-1
x=0
M-1
i2 (ux
M
vy
N
v=0
N-1
u=0
M-1
e
e
)
)
If M = N, we may also use
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 20
Properties of 2-D DFT Separability
F(u, v) = 1
Nf(x, y)
= 1
NN
1
Nf(x, y)
-i2 (ux+vy
N
y=0
N-1
x=0
N-1
-i2 (ux
N-i2 (
vy
N
y=0
N-1
x=0
N-1
e
e e
)
) )
{ }
1-D
1-D y
x
f(x,y)
v
x
F1(x,v)
v
u
F(u,v) N2 NN2 N
Periodicity f(x,y) = f(x+kN,y+lN), k, l = 0, 1, 2, .. F(u,v) = F(u+kN,v+lN)
Rotation f(r, + ) F(w, + ) 0 0
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 21
Translation f(x-x0,y-y0) F(u,v)e
-i2 (ux +vy
N0 0 )
f(x,y)ei2 (
u x+v y
N0 0 )
F(u-u0,v-v0)
e.g. if u0 = v0 = N/2
f x y F(u - , v - )(x+y)N / 2 N / 2( , )( )1
Conjugate Symmetry If f(x,y) is real, F(u,v) = F (-u,-v)
Distributivity f (x,y) + f (x,y) F (u,v) + F (u,v)
( f (x,y) f (x,y) F (u,v) F (u,v) )1 2 1 2
1 2 1 2
Scaling a f(x, y) a F(u,v)
f(ax,by) 1
abF(
u
a,v
b)
Average Value
f (x,y) = 1
Nf x y =
1
NF(0,0) 2
y=0
N-1
x=0
N-1
( , )
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 22
(Ref: http://www.cs.unm.edu/~brayer/vision/fourier.html)
(Ref: http://www.cs.unm.edu/~brayer/vision/fourier.html)
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 23
(Ref: http://www.cs.unm.edu/~brayer/vision/fourier.html)
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 24
Frequency-Domain Filtering
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 25
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 26
Smoothing Ideal Lowpass Filters
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 27
Butterworth Lowpass Filters
nDvuDvuH
20 ]/),([1
1),(
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 28
Gaussian Lowpass Filters 22 2/),(),( vuDevuH
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 29
Sharpening Ideal Highpass Filter
0
0
Dv)D(u, if 1
Dv)D(u, if 0v)H(u,
Butterworth Highpass Filter
2n0 v)]/D(u,[D1
1v)H(u,
Gaussian Highpass Filter
20
2 2/),(1v)H(u, DvuDe
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 30
Laplacian Filter
v))F(u,v+(u- y)f(x, 222
Unsharp Masking, High-Boost Filtering, and High-Frequency Emphasis Filters
),(1),(),(),(),( vuHvuHyxfyxfyxf lphplphp
),()1(),(
),(),()1(),(),(),(
vuHAvuH
yxfyxfAyxfyxAfyxf
hphb
lplphb
),(),( vubHavuH hphfe
original blurred image result
(Ref: http://www.astropix.com/HTML/J_DIGIT/USM.HTM)
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 31
Homomorphic Filter
normalsource
observeri(x,y)
r(x,y)
ln FFT H(u,v) FFT-1 expf(x,y) g(x,y)
f(x,y) = i(x,y) r(x,y) I(u,v) R(u,v)z(x,y) = ln f(x,y) = ln i(x,y) + ln r(x,y) LNI(u,v) + LNR(u,v)
slow spatial variation vary abruptly
H
H(u,v)
D(u,v)
L
H > 1L < 1
contrast enhancement
dynamic range compression
Original image Processed image
(Ref: http://www.vision.ee.ethz.ch/~pcattin/SIP/5-Enhancement.html )
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 32
Noise Suppression Noise Models
Usually image noise is assumed to be white and to be uncorrelated with the image.
Some Important Noise Probability Density Functions Gaussian Noise
22 2/)(
2
1)(
zezp
Remark: such as electronic circuit noise and sensor noise due to poor illumination and/or high temperature.
Rayleigh Noise
az
azeazbzp
baz
for 0
for )(2
)(/)( 2
4
)4(
4/
2
b
ba
Remark: such as noise in range imaging.
Erlang (Gamma) Noise
0for 0
0for )!1()(
1
z
zeb
zazp
azbb
22
a
ba
b
Remark: such as noise in laser imaging.
Exponential Noise (a special case of the Erlang pdf)
0for 0
0for )(
z
zaezp
az
22 1
1
a
a
Remark: such as noise in laser imaging. Uniform Noise
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 33
otherwise
bzabzp
0
afor 1
)(
12
)(
22
2 ab
ba
Remark: useful as the basis for numerous random number generation. Impulse (Salt-and-Pepper; Shot; Spike) Noise
otherwise 0
for
for
)( bzP
azP
zp b
a
Remark: found in situations where quick transients, such as faulty switching, take place during imaging.
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 34
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 35
Period Noise
Estimation of Noise Parameters If the imaging system is available, capture a set of images of “flat” environments. When only images are available, we may use small patches of reasonably constant gray level.
Szii
Szii
i
i
zpz
zpz
)()(
)(
22
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 36
Noise Suppression Mean Filters
Arithmetic Mean Filter
xySts
tsgmn
yxf),(
),(1
),(ˆ
Geometric Mean Filter
mn
Sts xy
tsgyxf1
),(
]),([),(ˆ
Harmonic Mean Filter
xySts tsg
mnyxf
),( ),(
1),(ˆ
Remark: works well for salt noise, but fails for pepper noise. Contraharmonic Mean Filter
xy
xy
Sts
Q
Sts
Q
tsg
tsg
yxf
),(
),(
1
),(
),(
),(ˆ
Remark: Q is called the order of the filter Positive Q eliminate pepper noise Negative Q eliminate salt noise Q = 0 arithmetic filter Q = -1 harmonic filter
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 37
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 38
Order-Statistics Filters Median Filter
)},({),(ˆ),(
tsgmedianyxfxySts
Remark: work well for both bipolar and unipolar impulse noise.
Max and Min Filters )},({max),(ˆ
),(tsgyxf
xySts )},({min),(ˆ
),(tsgyxf
xySts
Remark: Max filter works well for pepper noise. Min filter works well for salt noise.
Midpoint Filter
)}],({min)},({max[2
1),(ˆ
),(),(tsgtsgyxf
xyxy StsSts
Remark: work well for Gaussian noise and uniform noise.
Alpha-trimmed Mean Filter Suppose we delete the d/2 lowest and the d/2 highest gray-level values of g(s,t) in the neighborhood Sxy. Let gr(s,t) represent the remaining mn-d pixels.
xySts
r tsgdmn
yxf),(
),(1
),(ˆ
Remark: useful in situations involving multiple types of noise, such as a combination of salt-and-pepper and Gaussian noise.
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 39
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 40
Bilateral Filter Proposed by C. Tomasi and R. Manduchi, 1998. Based on geometric closeness and photometric similarity.
Linear filter
where
f(x): original image
c(,x): measure the geometric closeness between x and a nearby point
Bilateral filter
where
s(f(); f(x)): measure the photometric similarity between the pixel at x
and that of a nearby point . Example:
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 41
})),(
(2
1exp{),( 2
d
dc
x
x where xx ),(d
})))(),((
(2
1exp{),( 2
r
ffs
x
x where ff ),(
(Ref: http://www.cs.duke.edu/~tomasi/papers/tomasi/tomasiIccv98.pdf )
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 42
Periodic Noise Reduction Bandreject Filters
-- Ideal bandreject filter
2
Dv)D(u, if 1
2),(
2D if 0
2
Dv)D(u, if 1
),(
0
00
0
W
WDvuD
W
W
vuH
D(u,v): distance from the origin.
-- Butterworth
n
DvuD
WvuDvuH
220
2]
),(
),([1
1),(
-- Gaussian 2
20
2
]),(
),([
2
1
1),( WvuD
DvuD
evuH
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 43
Bandpass Filters ),(1),( vuHvuH brbp
Notch Filters
-- Ideal notch reject filter
otherwise 1
),(Dor ),(D if 0),( 0201 DvuDvu
vuH
2/120
202
2/120
201
])2/()2/[(),(
])2/()2/[(),(
vNvuMuvuD
vNvuMuvuD
-- Butterworth notch reject filter
n
vuDvuD
DvuH
]),(),(
[1
1),(
21
20
-- Gaussian notch reject filter 2
20
21 ]),(),(
[2
1
1),( D
vuDvuD
evuH
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 44
-- Notch pass filter ),(1),( vuHvuH nrnp
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 45
Optimum Notch Filtering
),(),(),( vuGvuHvuN
H(u,v): notch pass filter to pass only components associated with the interference pattern.
G(u,v): Fourier transform of the corrupted image.
)},(),({),( 1 vuGvuHyx
),(),(),(),(ˆ yxyxwyxgyxf
Objective: to select w(x,y) so that the variance of the estimate is minimized over a specified neighborhood of every point (x,y).
a
as
b
bt
yxftysxfba
yx 22 )],(ˆ),(ˆ[)12)(12(
1),(
where
a
as
b
bt
tysxfba
yxf ),(ˆ)12)(12(
1),(ˆ
2
2
]}),(),(),([
)],(),(),({[)12)(12(
1),(
yxyxwyxg
tysxtysxwtysxgba
yxa
as
b
bt
Assume that w(x,y) remains essentially constant over the neighborhood. ),(),( yxwtysxw
),(),(),(),( yxyxwyxyxw
2
2
)]},(),(),([
)],(),(),({[)12)(12(
1),(
yxyxwyxg
tysxyxwtysxgba
yxa
as
b
bt
0),(
),(2
yxw
yx
),(),(
),(),(),(),(),(
22 yxyx
yxyxgyxyxgyxw
Digital Image Processing (Fall, 2015)
NCTU EE Image Enhancement 46
Recommended