Вы находитесь на странице: 1из 72

Linear Image Processing and Filtering

n Math of 2-d linear systems


n Separability
n Shift-invariant linear systems, 2-d convolution
n Integral image for fast box-filtering
n 2-d frequency response
!
n Blurring and sharpening 1

n Zoneplate 0.8

0.6

n Image sampling/aliasing 0.4

0.2

Wiener filtering
0

n 2
3
2
0 1
wx 0
wx
n Nonlinear noise reduction/sharpening -2
-3
-2
-1

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 1
Linear image processing
n Image processing system S(.) is linear, iff superposition principle holds:

( ) ( )
S α ⋅ f #$ x, y %& + β ⋅ g #$ x, y %& = α ⋅ S f #$ x, y %& + β ⋅ S g #$ x, y %& for all α , β ∈! ( )
n Any linear image processing system can be written as
 
g = Hf Note: matrix H need not be square.
by sorting pixels into a column vector

( )
T
f = f ⎡⎣0,0 ⎤⎦ f ⎡⎣1,0 ⎤⎦  f ⎡⎣ N − 1,0 ⎤⎦ f ⎡⎣0,1⎤⎦  f ⎡⎣ N − 1,1⎤⎦   f ⎡⎣0, L − 1⎤⎦  f ⎡⎣ N − 1, L − 1⎤⎦

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 2
Impulse response
n Another way to represent any linear image processing scheme
N −1 L−1
g [α , β ] = ∑ ∑ f [ x, y ] ⋅ h [ x, α , y, β ]
x=0 y=0

impulse response
n Input: unit impulse at pixel [a,b]
$& 1 x = a ∧ y = b
f [ x, y ] = δ [ x − a, y − b ] = %
'& 0 else
n Output: impulse response
N −1 L−1
g [α , β ] = ∑ ∑ δ [ x − a, y − b ] ⋅ h [ x, α , y, β ] = h [ a, α ,b, β ]
x=0 y=0

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 3
Interpretation #1: superposition of impulse responses
δ [ x − a, y − b ] f [ a,b ] g [α , β ] = h [ a, α ,b, β ] f [ a,b ]
a
x +
α

b x

y β
a +
x
α

b x

y β +
Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 4
Interpretation #2: linear combination of input values
N −1 L−1
f [ x, y ] ⋅ h [ x, α , y, β ] g [α , β ] = ∑ ∑ f [ x, y ] ⋅ h [ x, α , y, β ]
x=0 y=0

x α
å x

y β

x
α

å
x

y β

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 5
Relationship of H and h[x,α,y,β ]

x® x® x®
•• •
¯a ¯a ¯a
x® x® x®
•• •
¯a ¯a ¯a
• • •
b¯ •





x® x® x®
•• •
¯a ¯a ¯a

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 6
Separable linear image processing
n Impulse response is separable in [x,α] and [y,β], i.e., can be written as
N −1 L−1
g [α , β ] = ∑ ∑ f [ x, y ] ⋅ hx [ x, α ] hy [ y, β ]
x=0 y=0
n Processing can be carried out
l row by row, then column by column
L−1 N −1
g [α , β ] = ∑ hy [ y, β ] ∑ f [ x, y ] ⋅ hx [ x, α ]
y=0 x=0

l column by column, then row by row


N −1 L−1
g [α , β ] = ∑ hx [ x, α ] ∑ f [ x, y ] ⋅ hy [ y, β ]
x=0 y=0

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 7
Separable linear image processing (cont.)

n If the digital input and output images are written as a matrices f and g, we can
conveniently write
g = H ⋅ f ⋅ Hx T
y

⎡ h 0,0 ⎤ ⎡ h 0,0 ⎤
y[ ] hy [ 0,1]  hy ⎡⎣ 0, Lg − 1⎤⎦ ⎢ x[ ] hx [ 0,1]  hx ⎡⎣ 0, N g − 1⎤⎦

⎢ ⎥
⎢ h 1,0 ⎥ ⎢ h 1,0 ⎥
y[ ] hy [1,1]  hy ⎡⎣1, Lg − 1⎤⎦ x[ ] hx [1,1]  hx ⎡⎣1, N g − 1⎤⎦
Hy = ⎢ ⎥ Hx = ⎢ ⎥
⎢ ⎥ ⎢    ⎥
   ⎢ ⎥
⎢ ⎥
⎢ hy [ L − 1,0 ] hy [ L − 1,1]  hy ⎡⎣ L − 1, Lg − 1⎤⎦ ⎥ ⎢ hx [ N − 1,0 ] hx [ N − 1,1]  hx ⎡⎣ N − 1, N g − 1⎤⎦ ⎥
⎣ ⎦ ⎣ ⎦

n Output image g has size Lg x Ng


n If the operator does not change image size, Hx and Hy are square matrices

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 8
Example: Separable Haar transform

Original Bike 256x256


256x256 Haar transform
Hx=Hy=Hr256

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 9
Haar transform

n Haar transform matrix for sizes N=2,4,8


æ 0 ö
1 æ 1 1 ö ç
1 1 2 0 2 0 0
÷
Hr2 =
2 çè 1 -1 ÷ø
ç 1 1 2 0 -2 0 0 0 ÷
ç ÷
ç 1 1 - 2 0 0 2 0 0 ÷
æ 1 1 2 0 ö 1 ç 1 1 - 2 0 0 -2 0 0 ÷
Hr8 = ç ÷
ç ÷ 8ç 1 -1 0 2 0 0 2 0 ÷
1 ç 1 1 - 2 0 ÷ ç ÷
Hr4 = ç 1 -1 0 2 0 0 -2 0 ÷
4ç 1 -1 0 2 ÷
÷ ç 1 -1 - 2 0 0 0 2 ÷
ç ç
0
÷
çè çè 0 0 0 -2 ÷ø
1 -1 0 - 2 ÷ø 1 -1 0 - 2

n Can be computed by taking sums and differences


n Fast algorithms by recursively applying Hr2

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 10
Example: Subsampling
n Image subsampling 2:1 horizontally and vertically
n Small input image of size 8x8, output image size 4x4
é 1 0 0 0 ù
ê ú
ê 0 0 0 0 ú
ê 0 1 0 0 ú
ê 0 0 0 0 ú
Hx = Hy = ê ú
ê 0 0 1 0 ú
ê 0 0 0 0 ú
ê 0 0 0 1 ú
ê ú
ë 0 0 0 0 û

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 11
Example: Subsampling (cont.)
n A somewhat better technique for 2:1 image size reduction

é 0.5 0 0 0 ù
ê ú
ê 0.5 0 0 0 ú
ê 0 0.5 0 0 ú
ê 0 0.5 0 0 ú
Hx = H y = ê ú
ê 0 0 0.5 0 ú
ê 0 0 0.5 0 ú
ê 0 0 0 0.5 ú
ê ú
ë 0 0 0 0.5 û

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 12
Side by side comparison
Hx = Hy = Hx = Hy =
! 1 0 0 0 $ ! 0.5 0 0 0 $
# & # &
# 0 0 0 0 & # 0.5 0 0 0 &
# 0 1 0 0 & # 0 0.5 0 0 &
# 0 0 0 0 & # 0 0.5 0 0 &
# & # &
# 0 0 1 0 & # 0 0 0.5 0 &
# 0 0 0 0 & # 0 0 0.5 0 &
# 0 0 0 1 & # 0 0 0 0.5 &
# & # &
" 0 0 0 0 % " 0 0 0 0.5 %

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 13
Another example: filtering
n Each pixel is replaced by the average of two horizontally (vertically) neighboring
pixels
⎡ 0.5 0  0 ⎤
⎢ ⎥
⎢ 0.5 0.5 ⎥
⎢ 0 0.5 0.5 ⎥
⎢ 0.5 0.5   ⎥
Hx = Hy = ⎢ ⎥
⎢ 0.5 0.5 ⎥
⎢   0.5 0.5 ⎥
⎢ 0.5 0.5 0 ⎥
⎢ ⎥
⎣ 0  0 0.5 0.5 ⎦

n Shift-invariant operation (except for image boundary)

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 14
Shift-invariant systems and Toeplitz matrices
n For a separable, shift-invariant, linear system
hx [x, a ] = hsiv/x [a - x ] and hy [y, b ] = hsiv/y [b - y ]

n Matrices Hx and Hy are square, and Toeplitz matrices, e.g.,


⎡ h [0] hsiv/x [1]  hsiv/x [ N − 1] ⎤
⎢ siv/x

⎢ hsiv/x [ −1] hsiv/x [ 0 ]  hsiv/x [ N − 2 ] ⎥
Hx = ⎢ ⎥
⎢    ⎥
⎢ hsiv/x [1− N ] hsiv/x [ 2 − N ]  hsiv/x [ 0 ] ⎥
⎣ ⎦
n Operation is a 2-d separable convolution („filtering“)
N -1 L-1
g [a , b ] = å å f [x, y ]× hsiv/x [a - x ]hsiv/y [b - y ]
x=0 y=0

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 15
Non-separable 2-d convolution
n Convolution kernel of linear shift-invariant system („filter“) can also be
non-separable
N -1 L-1
g [a , b ] = å å f [x, y ]× hsiv [a - x, b - y ]
x=0 y=0

n Viewed as a matrix operation . . .


 
g = Hf
. . . H is a block Toeplitz matrix

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 16
Structure of H for non-separable convolution

x® x® x®
•• •
¯a ¯a ¯a
x® x® x®
•• •
¯a ¯a ¯a
• • •
b¯ •





x® x® x®
•• •
¯a ¯a ¯a

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 17
Convolution: superposition of impulse responses
f [ a,b ]δ [ x − a, y − b ] g [ x, y ] = hsiv [ x − a, y − b ] f [ a,b ]
a +
x x

b x 1 x 5
2 3 4

y
+
y a +
x x

b x 1 x 5
2 3 4
y
+
y +
Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 18
Convolution: linear combination of neighboring pixel values
N -1 L-1

f [ x, y ] ⋅ hsiv [α − x, β − y ] g [a , b ] = å å f [x, y ]× hsiv [a - x, b - y ]


x=0 y=0
α
x x

4 3 2
5 x 1 å xx β

y
+
y
x x

4 3 2
5 x 1 å x β
+
y y α

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 19
Convolution examples

Original Bike blurred by convolution


Bike Impulse response „box filter“
⎛ 1 1 1 1 1 ⎞
⎜ 1 1 1 1 1 ⎟
1 ⎜ ⎟

25 ⎜
1 1 [1] 1 1 ⎟
⎜ 1 1 1 1 1 ⎟⎟
⎝ 1 1 1 1 1 ⎠

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 20
Convolution examples

Original Bike blurred horizontally


Bike Filter impulse response

1
5 (
1 1 [1] 1 1 )

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 21
Convolution examples

Original Bike blurred vertically


Bike Filter impulse response

⎛ 1 ⎞
⎜ 1 ⎟
1⎜ ⎟

5⎜
[1] ⎟
⎜ 1 ⎟⎟
⎝ 1 ⎠

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 22
Integral image

Σ j [x, y ] = j [x, y - 1]+ f [x, y ]


i [x, y ] = i [x - 1, y ]+ j [x, y ]

f [x, y ]
x
i [x, y ]= å å f [u,v ]
u=0 v=0

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 23
Box filtering with integral image

Σ
B D

C A

Sum = A + B – C – D

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 24
Gaussian filtering by repeated box filtering
N times

≈ ∗ … ∗

Variance σ2 σ 12 / N

n Approximate convolution with Gaussian kernel by


convolution with box kernel, repeated N times
n Convolution with box kernel can be computed efficiently
using integral image

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 25
Gaussian filtering by repeated box filtering
Direct implementation:
6561 multiplications and
6560 additions per pixel

x-y separable filtering:


162 multiplications and
160 additions per pixel

Original image Gaussian filtered


500x500 σ = 20, 81x81 kernel

20 additions or subtractions per pixel

Box filtered Box filtered Box filtered Box filtered


after N = 1 after N = 2 after N = 3 after N = 4

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 26
1-d discrete-time Fourier transform
n Given a 1-d sequence s[k ] , k ∈Z = {…,−1,0,1,2, 3,…}
n Fourier transform

S e( )jω
= ∑ ⎣ ⎦
s ⎡
k=−∞
k ⎤ e − jω k
ω ∈ℜ

n Fourier transform is periodic with 2π


n Inverse Fourier transform
1
( )
π
s ⎡⎣ k ⎤⎦ =
2π ∫−π
S e jω e jω k dω

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 27
2-d discrete-space Fourier transform
n Given a 2-d array of image samples
s [m, n ] , m, n ÎZ 2
n Fourier transform

( )
∞ ∞

∑ ∑ s ⎡⎣ m,n ⎤⎦ e
jω y − jω x m− jω y n
S e jω x ,e = ω x ,ω y ∈ℜ 2
m=−∞ n=−∞

n Fourier transform is 2π-periodic both in ω x and ω y


n Inverse Fourier transform

s ⎡⎣ m,n ⎤⎦ =
1
4π 2
π
∫ ∫
−π −π
π
(
S e jω x
,e
jω y
)e jω x m+ jω y n
d ω x dω y

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 28
5x5 box filter revisited

Original Bike blurred by convolution


Bike Impulse response „box filter“
⎛ 1 1 1 1 1 ⎞
⎜ 1 1 1 1 1 ⎟
1 ⎜ ⎟

25 ⎜
1 1 [1] 1 1 ⎟
⎜ 1 1 1 1 1 ⎟⎟
⎝ 1 1 1 1 1 ⎠

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 29
Frequency response of 5x5 lowpass filter

( )
∞ ∞

∑ ∑ h ⎡⎣ m,n ⎤⎦ e
jω x jω y − jω x m− jω y n
H e ,e =
m−∞ n=−∞

1 2 2 − jω x m− jω y n 1 2 − jω x m 2 − jω y n
= ∑ ∑e
25 m=−2 n=−2
= ∑e ∑e
25 m=−2 n=−2

!
( )
1
1
0.8
=
25
(1+ 2cosω x + 2cos(2ω x )) 1+ 2cosω y + 2cos(2ω y )
0.6

0.4

0.2
Separable filter:
1-d frequency responses
0 are multiplied
2
3
2
0 1
wx -2 -2
-1
0
wx
-3

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 30
Horizontal lowpass filter
(
H e jω x ,e
jω y
) =
1
5
(1+ 2cosω x + 2cos(2ω x ))

! 1

0.8

0.6

0.4

0.2

Bike blurred horizontally 2


3
2
Filter impulse response 0 1
wx -1
wx
0

( )
-2 -2
1
[1]
-3
1 1 1 1
5

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 31
Vertical lowpass filter

(
H e jω x ,e
jω y
) (
=
1
5
1+ 2cos ω y + 2cos(2ω y ) )
1

0.8

0.6

0.4

0.2

Bike blurred vertically 2


3
2
Filter impulse response wy
0 1

wx
0
-2 -1
⎛ 1 ⎞ -3
-2

⎜ ⎟
1
1⎜ ⎟
⎜ ⎡1⎤ ⎟
5⎜ ⎣ ⎦ ⎟
⎜ 1 ⎟
⎜⎝ 1 ⎟⎠

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 32
Sharpening filter

Original Bike sharpened


Bike Filter impulse
response
æ 0 -1 0 ö
1ç ÷
-1 [8 ] -1
4 çç ÷
è 0 -1 0 ÷ø

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 33
Frequency response of sharpening filter

( )
∞ ∞

∑ ∑ h ⎡⎣ m,n ⎤⎦ e
jω x jω y − jω x m− jω y n
3 H e ,e =
! m−∞ n=−∞

( )
2.5
1 − jω jω − jω jω
= 8− e x − e x − e y − e y
2 4
1 1
1.5
= 2 − cos ω x − cos ω y
2 2
1
4
2 4
2
wy
0
0
-2
-4 -4
-2
wx

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 34
More aggressive sharpening

(
H e jω x ,e
jω y
) = 5 − 2cosω x
− 2cos ω y

!
10

0
Bike sharpened 4
2 4
Filter impulse response 0 2

wx -2 -2
wx
0

æ 0 -1 0 ö -4 -4
ç -1 5 -1 ÷
ç [] ÷
ç 0 -1 0 ÷
è ø

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 35
Zoneplate pattern to visualize frequency plane
Equation to generate pattern:
s(x, y) = ŝ cos(ax x 2 + a y y 2 ) + s0
Local frequency at ( x, y )

∂x
( )
ax x 2 + a y y 2 = 2ax x


∂y
( )
ax x 2 + a y y 2 = 2a y y
x
⎯ ⎯⎯⎯⎯
interpolation
s ⎡⎣ x, y ⎤⎦ ←⎯⎯⎯ → s(x, y)
sampling

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 36
Sampling interpretation of 2-d discrete-space Fourier transform

n How is the Fourier transform of s[m,n] related to the Fourier transform of the
continuous signal
∞ ∞
s ( x, y ) = ∑ ∑ s !" m,n #$ δ ( x − m, y − n)2
m=−∞ n=−∞

„continuous“
continuous delta function
discrete

n Continuous-space 2-d Fourier transform



( )
∞ ∞

∑ ∑ s ⎡⎣ m,n ⎤⎦ δ 2 ( x − m, y − n) e
− jω x x− jω y y
S ω x ,ω y = ∫ ∫ dx dy
x y m=−∞ n=−∞

( )
∞ ∞

∑ ∑ s ⎡⎣ m,n ⎤⎦ e
− jω x m− jω y n jω y
= = S e jω x ,e
m=−∞ n=−∞

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 37
Lowpass filtering

Original Zoneplate (512x512) Lowpass filtered with 5x5 box filter

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 38
Zoneplate demonstration: 1-d sampling of 2-d signals

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 39
Zoneplate demonstration: 1-d sampling of 2-d signals

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 40
Zoneplate demonstration: 1-d sampling of 2-d signals

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 41
Zoneplate demonstration: 1-d sampling of 2-d signals

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 42
Zoneplate demonstration: 1-d sampling of 2-d signals

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 43
Zoneplate demonstration: 1-d sampling of 2-d signals

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 44
Zoneplate demonstration: 1-d sampling of 2-d signals

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 45
Zoneplate demonstration: 2-d sampling of 2-d signals

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 46
Horizontal/vertical 2:1 subsampling without prefiltering

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 47
Horizontal/vertical 2:1 subsampling with prefiltering
2d impulse response Frequency response
æ 1 1 1 ö
ç 16 8 16 ÷ 1
ç ÷
ç 1 1 1 ÷
ç 8 4 8 ÷ 0.5

|H|
ç ÷
ç 1 1 1 ÷
çè 16 8 16 ÷ø 0
2
0 2
0
-2 -2
wy wx

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 48
Image magnification (10%)

Nearest neighbor interpolation Bilinear interpolation

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 49
Optical anti-aliasing filter removal

http://www.mosaicengineering.com/products/vaf/60d/remove.html

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 50
Optical anti-aliasing filter removal

without anti-aliasing with anti-aliasing

maxmax.com

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 51
Temporal aliasing (“wagon-wheel effect”)

youtube.com/watch?v=jHS9JGkEOmA
Blurry images

Point source on focal plane maps to point

focal plane

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 53
Blurry images

Away from focal plane: out-of-focus blur

blurred point
focal plane

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 54
Blurry images

Linear + shift-invariant è convolution!

focal plane

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 55
Blurry images

Motion blur: convolution as well.

focal plane

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 56
Image deconvolution
n Given an image f [x,y] that is a blurred version of original image s[x,y], recover the
original image.
n

Assume linear shift-invariant blur, transfer function B e jω x ,e y ( )
s [x, y ] (
B e jω x ,e
jω y
) f [x, y ] (
H e jω x ,e
jω y
) g [x, y ]
blur recovery
filter

n Naive solution: inverse filter


H e ( jω x
,e
jω y
) = B(e 1
jω x
,e
jω y
)
n ( )
Problem: B e jω x ,e jω y might be zero, noise amplification

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 57
Naïve deconvolution
Original (
Blurred w/ B e jω x ,e
jω y
) (
Deblurred w/ B −1 e jω x ,e
jω y
)

+ white noise rms = 2.5

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 58
Wiener filtering
n Model

s [x, y ]
filtering
& noise f [x, y ]
(
H e jω x ,e
jω y
) g [x, y ]
recovery
filter
n Minimize mean squared estimation error
{( ) } ⎯⎯⎯⎯⎯→ min.
H ⎛⎜ e
jω y ⎞

{ }
jω x
2 ,e ⎟⎠

E e ⎡⎣ x, y ⎤⎦ = E g ⎡⎣ x, y ⎤⎦ − s ⎡⎣ x, y ⎤⎦
2

n Power spectral density of estimation error


(
Φ ee e jω x ,e
jω y
) (
= Φ gg e jω x ,e
jω y
) ( ) (
− Φ gs e jω x ,e
jω y
) ( )
− Φ sg e jω x ,e
jω y
+ Φ ss e jω x ,e
jω y

= Φ ff (e jω x
,e
jω y
) H (e ,e ) H (e ,e ) − Φ (e ,e ) H (e ,e )
jω x jω y ∗ jω x jω y
fs
jω x jω y jω x jω y

− Φ ( e ,e ) H ( e ,e ) + Φ ( e ,e )
jω x jω y ∗ jω x jω y jω x jω y
sf ss

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 59
Review: Power spectrum and cross spectrum
n 2-d discrete-space cross correlation function for ergodic, stationary signals
{
ϕ fg ⎡⎣ m,n ⎤⎦ = E f ⎡⎣ x + m, y + n ⎤⎦ g ∗ ⎡⎣ x, y ⎤⎦ }
n Special case: autocorrelation function
{
ϕ ff ⎡⎣ m,n ⎤⎦ = E f ⎡⎣ x + m, y + n ⎤⎦ f ∗ ⎡⎣ x, y ⎤⎦ }
n Cross spectral density

( )
∞ ∞

∑ ∑ ϕ fg ⎡⎣ m,n ⎤⎦ e
jω x jω y − jω x m− jω y n
Φ fg e ,e =
m=−∞ n=−∞

n Power spectral density


( )= ∑ ∑ϕ
∞ ∞
jω x jω y − jω x m− jω y n
Φ ff e ,e ff
⎡⎣ m,n ⎤⎦ e
m=−∞ n=−∞

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 60
Wiener filtering (cont.)
n Power spectrum Φee is minimized separately at each frequency ω x , ω y if

H e ( jω x
,e
jω y
) =
Φ∗fs e ( jω x
,e
jω y
)= (
Φ sf e
jω x
,e
jω y
)
Φ ff (e jω x
,e
jω y
) Φ (e
ff
jω x
,e
jω y
)
n Can be shown to be global minimum by considering filter

H e( jω x
,e
jω y
) =
(
Φ∗fs e jω x ,e
jω y
) + ΔH (e jω x jω y
)
(e )
jω y
,e
jω x
Φ ff ,e

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 61
Wiener filter for linear distortion and additive noise
statistically
independent n [x, y ]

s [x, y ] (
B e jω x ,e
jω y
) å
f [x, y ] (
H e jω x ,e
jω y
) g [x, y ]

(
Φ sf e jω x ,e
jω y
) (
= Φ ss e jω x ,e
jω y
) ( B∗ e jω x ,e
jω y
)
Φ (e ) = Φ (e ) B(e ) ( )
2
jω x jω y jω x jω y jω x jω y jω y
ff
,e ss
,e ,e + Φ nn e jω x ,e

H e( jω x
,e
jω y
)= (
Φ ss e jω x ,e ) ( jω y
B∗ e jω x ,e
jω y
)
( ) B (e ,e ) ( )
2
jω x jω y jω x jω y jω y
Φ ss e ,e + Φ nn e jω x ,e

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 62
Wiener filter for linear distortion and additive noise
( )
Wiener Filter
jω x jω y Deblurred
Blurred w/ B e ,e ( ) B (e ,e )
( )
jω x jω y ∗ jω x jω y
Φ ss e ,e
jω x jω y
Add. white noise, rms = 2.5 B −1 e ,e (
Φ ss e jω x ,e
jω y
) B (e ,e ) + Φ (e
jω x jω y
2

nn
jω x
,e
jω y
)

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 63
Wiener filter for additive noise
statistically
independent n [x, y ]

s [x, y ]
å
f [x, y ] (
H e jω x ,e
jω y
) g [x, y ]

H e( jω x
,e
jω y
) = Φ (e (
Φ ss e jω x ,e
jω y
)
ss
jω x
,e
jω y
) (
+ Φ nn e jω x ,e
jω y
)

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 64
Wiener filter for additive noise

Original Additive
white noise

rms = 17.7

Noise reduction
by Wiener filtering

rms = 8.8

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 65
Nonlinear noise reduction/sharpening
n Noise reduction: smooth the image, lowpass filtering
n Deblurring: sharpen edges, highpass filtering
n How can both be achieved simultaneously?
n Key insight: large amplitude of highpass filtered image indicates presence of
edge
α ( f "# x, y $% ) h

HPF
(
Z e jwx , e
jw y
) fh éë x, y ùû
- fh éë x, y ùû
f [x, y] + g [x, y ]
å å

n Can be extended to multiple HPFs

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 66
Nonlinear noise reduction/sharpening (cont.)
HPF Soft coring
(
α f i "# x, y $% )
(
Z1 e
jω x
,e
jω y
) - f1 éë x, y ùû
!(.)

f [x, y ] + g [x, y ]
å å
fi éë x, y ùû
-

m
pe
HPF Soft coring

S lo
Z2 e ( jω x
,e
jω y
) f2 éë x, y ùû !(.)

n Flat areas: α ≈ 0 → H e jω x ,e ( jω y
) ) ( )
≈ 1− Z1 e jω x ,e( jω y
− Z 2 e jω x ,e
jω y

n f1 small; f2 large: H e jω x ,e ( jω y
) ≈ 1− Z (e ,e ) + ( m − 1) Z (e ,e )
1
jω x jω y
2
jω x jω y

H (e ) ≈ 1+ ( m − 1) Z (e ,e ) − Z (e ,e )
jω x jω y jω x jω y jω x jω y
n f1 large; f2 small: ,e 1 2

n Both large: (
H e jω x ,e
jω y
) ⎣

( jω
) (
≈ 1+ ( m − 1) ⎡⎢ Z1 e jω x ,e y + Z 2 e jω x ,e y ⎤⎥
⎦ )
Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 67
Nonlinear noise reduction/sharpening example

blurred, noisy image noise-reduced


and sharpened

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 68
Highpass filtered images

log magnitude of log magnitude of log magnitude of log magnitude of


image filtered with image filtered with image filtered with image filtered with
æ 0 0 0 ö æ 0 - 0.5 0 ö æ - 0.5 0 0 ö æ 0 0 - 0.5 ö
ç ÷ ç ÷ ç ÷ ç ÷
ç - 0.5 [1] - 0.5 ÷ ç 0 [1] 0 ÷ ç 0 [1] 0 ÷ ç 0 [1] 0 ÷
ç 0 0 0 ÷ø ç 0 - 0.5 0 ÷ ç 0 0 - 0.5 ÷ø ç - 0.5 0 0 ÷ø
è è ø è è

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 69
Soft coring function
⎛ f i ⎡⎣ x,y ⎤⎦ ⎞
γ

( )

α f i ⎡⎣ x, y ⎤⎦ = m ⋅ f i ⎡⎣ x, y ⎤⎦ ⋅ ⎜ 1− e ⎟
τ

⎜ ⎟
⎝ ⎠
Example:
m=3
g =2
τ = 10
(
α f i ⎡⎣ x, y ⎤⎦ )

f i ⎡⎣ x, y ⎤⎦
Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 70
Soft coring of highpass filtered images

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 71
Linear vs. nonlinear noise reduction/sharpening

Noise reduction by Sharpening by highpass Combined noise reduction and


lowpass filter (linear) filter (linear) sharpening (nonlinear)

Digital Image Processing: Bernd Girod, © 2013-2018 Stanford University -- Linear Image Processing and Filtering 72

Вам также может понравиться