You are on page 1of 51

Digital Image Processing

Image Restoration and Reconstruction


(Linear Restoration Methods)
Christophoros Nikou
cnikou@cs.uoi.gr

University of Ioannina - Department of Computer Science

Contents

In this lecture we will look at linear image


restoration techniques
Differentiation of matrices and vectors
Linear space invariant degradation
Restoration in absence of noise
Inverse filter
Pseudo-inverse filter

Restoration in presence of noise


Inverse filter
Wiener filter
Constrained least squares filter

C. Nikou Digital Image Processing (E12)

Differentiation of Matrices and


Vectors
Notation:
A is a MxN matrix with elements aij.
x is a Nx1 vector with elements xi.
f(x) is a scalar function of vector x.
g(x) is a Mx1 vector valued function of vector x.

C. Nikou Digital Image Processing (E12)

Differentiation of Matrices and


Vectors (cont...)
Scalar derivative of a matrix.
A is a MxN matrix with elements aij.

a11
K
t
A
M O
t
aM 1

L
t

a1N

M
aMN

C. Nikou Digital Image Processing (E12)

Differentiation of Matrices and


Vectors (cont...)
Vector derivative of a function (gradient).
x is a Nx1 vector with elements xi.
f(x) is a scalar function of vector x.

f
f
x f
K
x
x1

xN

C. Nikou Digital Image Processing (E12)

Differentiation of Matrices and


Vectors (cont...)

Vector derivative of a vector (Jacobian):


x is a Nx1 vector with elements xi.
g(x) is a Mx1 vector valued function of vector x.

g1
x
1

M
g M
x
1

K
O
L

g1
xN

g M
xN

C. Nikou Digital Image Processing (E12)

Differentiation of Matrices and


Vectors (cont...)

Some useful derivatives.


x is a Nx1 vector with elements xi.
b is a Nx1 vector with elements bi.
T
b x b

It is the derivative of the scalar valued function


bTx with respect to vector x.
C. Nikou Digital Image Processing (E12)

Differentiation of Matrices and


Vectors (cont...)

Some useful derivatives.


x is a Nx1 vector with elements xi.
A is a MxN matrix with elements aij.
T
T
x
Ax

A
x

x
If A is symmetric:

T
x Ax 2Ax

x
C. Nikou Digital Image Processing (E12)

Differentiation of Matrices and


Vectors (cont...)

Some useful derivatives.


x is a Nx1 vector with elements xi.
b is a Nx1 vector with elements bi.
A is a MxN matrix with elements aij.

2
T
Ax b 2A Ax b
x

It may be proved using the previous properties.


C. Nikou Digital Image Processing (E12)

10

Linear, Position-Invariant
Degradation
We now consider a degraded image to be
modelled by:

g ( x, y ) h ( x, y ) f ( x, y ) ( x, y )
where h(x, y) is the impulse response of the
degradation function ( i.e. point spread function
blurring the image).
The convolution implies that the degradation
mechanism is linear and position invariant (it
depends only on image values and not on
location).
C. Nikou Digital Image Processing (E12)

11

Linear, Position-Invariant
Degradation (cont...)
In the Fourier domain:

G (k , l ) H (k , l ) F (k , l ) N (k , l )
where multiplication is element-wise.
In matrix-vector form:

g = Hf +
where H is a doubly block circulant matrix and
f,g, and are vectors (lexicographic ordering).
C. Nikou Digital Image Processing (E12)

12

Linear, Position-Invariant
Degradation (cont...)
g ( x , y ) h ( x , y ) f ( x , y ) ( x, y )
G (k , l ) H (k , l ) F (k , l ) N ( k , l )
g = Hf +
If the degradation function is unknown the
problem of simultaneously recovering f(x,y)
and h(x,y) is called blind deconvolution.
C. Nikou Digital Image Processing (E12)

13

Linear Restoration
Using the imaging system

g = Hf +
we want to estimate the true image from the
degraded observation with known
degradation H.
A linear method applies an operator (a
matrix) P to the observation g to estimate
the unobserved noise-free image f:

f = Pg
C. Nikou Digital Image Processing (E12)

14

Restoration in Absence of Noise


The Inverse Filter
When there is no noise:

g = Hf
an obvious solution would be to use the
inverse filter:

P=H

-1

yielding

f = Pg = H -1g = H -1Hf = f
C. Nikou Digital Image Processing (E12)

15

Restoration in Absence of Noise


The Inverse Filter (cont...)
f = H -1g
For a NxN image, H is a N2xN2 matrix!
To tackle the problem we transform it to the
Fourier domain.
H is doubly block circulant and therefore it
may be diagonalized by the 2D DFT matrix
W:
-1

H = WW

C. Nikou Digital Image Processing (E12)

Restoration in Absence of Noise


The Inverse Filter (cont...)

16

-1

where

H = WW

diag{H (1,1),..., H ( N ,1), H (1, 2),...H ( N , N )}


Therefore:
-1
-1
f = Pg f = H -1g f = (WW)
g
-1 -1
-1 -1

f = W Wg Wf = WW Wg

-1

F = G
C. Nikou Digital Image Processing (E12)

17

Restoration in Absence of Noise


The Inverse Filter (cont...)
Which is the vectorized form of the DFT of
the image:

G
(
k
,
l
)
F = G F (k , l ) =
H (k , l )
-1

Take the inverse DFT and obtain f(m,n).


Problem: what happens if H(k,l) has zero
values?
Cannot perform inverse filtering!
C. Nikou Digital Image Processing (E12)

18

Restoration in Absence of Noise


The Pseudo-inverse Filter
A solution is to set:

G (k , l )
, H (k , l ) 0

F (k , l ) = H (k , l )

0
, H (k , l ) 0

which is a type of pseudo-inversion.


Notice that the signal cannot be restored at
locations where H(k,l)=0.
C. Nikou Digital Image Processing (E12)

19

Restoration in Absence of Noise


The Pseudo-inverse Filter (cont...)
A pseudo-inverse filter also arises by the
unconstrained least squares approach.
Find the image f, that, when it is blurred by
H, it will provide an observation as close as
possible to g, i.e. It minimizes the distance
between Hf and g.

C. Nikou Digital Image Processing (E12)

20

Restoration in Absence of Noise


The Pseudo-inverse Filter (cont...)
This distance is expressed by the norm:

J (f ) Hf - g
J

min J (f )
0
f
f
f

Hf - g 0

2HT Hf - g 0 2HT Hf 2HT g

f H H HT g
T

C. Nikou Digital Image Processing (E12)

21

Restoration in Presence of Noise


The Inverse Filter
Recall the imaging model with spatially
invariant degradation and noise

g ( x , y ) h ( x , y ) f ( x , y ) ( x, y )
G (k , l ) H (k , l ) F (k , l ) N ( k , l )
g = Hf +

C. Nikou Digital Image Processing (E12)

22

Restoration in Presence of Noise


The Inverse Filter (cont...)
Applying the inverse filter in the Fourier
domain:

G (k , l ) H (k , l ) F (k , l ) N (k , l )
N
(
k
,
l
)
F (k , l ) F (k , l )
H (k , l )
Even if we know H(k,l) we cannot recover F(k,l)
due to the second term.
If H(k,l) has small values the second term
dominates (it goes to infinity if H(k,l)=0!).
C. Nikou Digital Image Processing (E12)

23

Restoration in Presence of Noise


The Inverse Filter (cont...)
One approach to get around the problem is
to limit the ratio G(k,l) / H(k,l) to frequencies
near the origin that have lower probability of
being zero.
We know that H(0,0) is usually the highest
value of the DFT.
Thus, by limiting the analysis to frequencies
near the origin we reduce the probability of
encountering zero values.
C. Nikou Digital Image Processing (E12)

24

Restoration in Presence of Noise


The Inverse Filter (cont...)
Blurring degradation

C. Nikou Digital Image Processing (E12)

25

Restoration in Presence of Noise


The Inverse Filter (cont...)
Inverse filter with cut-off

C. Nikou Digital Image Processing (E12)

26

Restoration in Presence of Noise


Wiener Filter
So far we assumed nothing about the statistical
properties of the image and noise.
We now consider image and noise as random
variables and the objective is to find an estimate of
the uncorrupted image f such that the mean square
error between the estimate and the image is
minimized:

(f f ) 2
min
E

where E[x] is the expected value of vector x.


C. Nikou Digital Image Processing (E12)

27

Restoration in Presence of Noise


Wiener Filter (cont...)
Recall also the definition of the correlation
matrix between two vectors x and y:
R xy E xy

E x1 y1

E xN y1

E x1 y2
M

E xN y2

E x1 y N

M
M
K
K E xN y N
K

We assume that the image and the noise are


uncorrelated:
R f R f 0
C. Nikou Digital Image Processing (E12)

28

Restoration in Presence of Noise


Wiener Filter (cont...)
We are looking for the best estimate:

min
E
(
f

f
)

Lets confine our estimate to be obtainable by


a linear operator on the observation:
f Pg
and the goal is to find the best matrix P.
C. Nikou Digital Image Processing (E12)

29

Restoration in Presence of Noise


Wiener Filter (cont...)

J (f ) E (f f )

2
2

E f f
E f Pg

T
n

Denoting by p the n-th row of P:

J (f ) E

p g
T
n

2
T

E f n p n g

C. Nikou Digital Image Processing (E12)

Restoration in Presence of Noise


Wiener Filter (cont...)

30

J (f ) E f n p g f n p g

n
T
n

T
n

T
T
T
T
T
T

E f nf n p n gf n f n g p n p n gg p n
n

T
T
T
T
T
T

E f nf n p n E
gf n
E f n g p n p n E
gg p n
n

R fnfn 2pTn R gfn pTn R gg p n


n

C. Nikou Digital Image Processing (E12)

31

Restoration in Presence of Noise


Wiener Filter (cont...)
We can now minimize the sum with respect
to each term:

T
T
R fnfn 2p n R gfn p n R gg p n 0
p n

1
R gfn
2R gfn 2R gg p n 0 p n R gg

p R fn g R
T
n

1
gg

C. Nikou Digital Image Processing (E12)

32

Restoration in Presence of Noise


Wiener Filter (cont...)
Assembling the rows together:

P R fg R

1
gg

We have to compute the two matrices:


T

(Hf Hf
R gg E gg E
)(

E Hff H Hf f H
T

HR ff HT HR f R f HT R
C. Nikou Digital Image Processing (E12)

Restoration in Presence of Noise


Wiener Filter (cont...)

33

Assumming noise is uncorrelated with image:


R gg HR ff
H R
T

Also,
f (Hf )T ...R Hff
R fg E fgT E

Finally the matrix we are looking for is


1
gg

P R fg R R ff H

HR

H R
T

ff

C. Nikou Digital Image Processing (E12)

34

Restoration in Presence of Noise


Wiener Filter (cont...)
The estimated uncorrupted image is
f Pg f R HT HR HT R 1 g
ff

ff

which may be also expressed as

f H R H R
T

1 1
ff

HT R 1 g

This result is known as the Wiener filter or


the minimum mean square error (MMSE)
filter.
C. Nikou Digital Image Processing (E12)

35

Restoration in Presence of Noise


Wiener Filter (cont...)
Special cases:
No blur (H=I, g=f+): f R ff R ff R

g
No noise (R=0, g=f):
This is the inverse filter.

No blur, no noise (H=I, R=0): f g


Do nothing on the observation.
C. Nikou Digital Image Processing (E12)

36

Restoration in Presence of Noise


Wiener Filter (cont...)
The size of the matrix to be inverted poses
difficulties and Wiener filter is implemented in
the Fourier domain.
This occurs when H is doubly block circulant
(represents convolution) and the image f and
noise are wide-sense stationary (w.s.s).
Definition of a w.s.s. signal:
1) E[f(m,n)]=, independent of m,n.
2) E[f(m,n)f(k,l)]=r(m-k,n-l), independent of
location.
C. Nikou Digital Image Processing (E12)

37

Restoration in Presence of Noise


Wiener Filter (cont...)
Reminder: the inverse DFT complex exponential
matrix diagonalizes any circulant matrix:
1

H W W
H
The columns of W-1 are the eigenvectors of any
circulant matrix H.
The corresponding eigenvalues are the DFT values
of the signal producing the circulant matrix.
Remember also that WT W
1 T
1
and that
W
W

C. Nikou Digital Image Processing (E12)

Restoration in Presence of Noise


Wiener Filter (cont...)

38

We will employ the following relations:


1

H W W
H
H W W
H

W W
H

If H is real:

H H
T

T *

( NW)

*
H

1
W
N

1 *

W
*

W
W

*
H

C. Nikou Digital Image Processing (E12)

*
H

1 *

Restoration in Presence of Noise


Wiener Filter (cont...)

39

The Wiener solution is now transformed to


the Fourier domain:
f R ff H T HR ff
HT R

g
1

( W W
)(
W W ) W
( W
)(
W W
)(
W W ) W
( W ) g
ff
H
ff
1

W
ff W W
1

*
H

*
H

(
H
ff

Wf ff
H ( H ff

*
H

*
H

*
H

) g

Wg
)

Notice that the matrices are diagonal.


C. Nikou Digital Image Processing (E12)

40

Restoration in Presence of Noise


Wiener Filter (cont...)

*

Wf
ff
H ( H ff

*
H

Wg
) 1

F (k , l )

S ff (k , l ) H (k , l )
2

S ff (k , l ) H (k , l ) S (k , l )

G (k , l )

Sff (k,l)=DFT(Rff (m,n)) is the power spectrum of


the image f (m,n).
S(k,l)=DFT(R (m,n)) is the power spectrum
of the noise (m,n).
C. Nikou Digital Image Processing (E12)

41

Restoration in Presence of Noise


Wiener Filter (cont...)
If Sff (k,l) is not zero we may define the Signal
to Noise Ratio in the frequency domain:

SNR(k , l )

S ff (k , l )
S (k , l )

and the Wiener filter becomes:

F (k , l )

H (k , l )
2

H (k , l ) SNR -1 (k , l )
C. Nikou Digital Image Processing (E12)

G (k , l )

42

Restoration in Presence of Noise


Wiener Filter (cont...)
A well known estimate of Sff (k,l) is the
periodogram (the ML estimate of Rff when f ia
assumed Gaussian):
1
2
S ff (k , l )
F (k , l )
MN

In practice, as F(k,l) is unknown, we use


1
2

S ff (k , l )
G (k , l )
MN
C. Nikou Digital Image Processing (E12)

43

Restoration in Presence of Noise


Wiener Filter (cont...)

C. Nikou Digital Image Processing (E12)

44

Restoration in Presence of Noise


Wiener Filter (cont...)
Degraded image

Inverse

Noise variance one order


of magnitude less.

Noise variance ten orders


of magnitude less.
C. Nikou Digital Image Processing (E12)

Wiener

45

Restoration in Presence of Noise


Constrained Least Squares Filter
When we do not have information on the power
spectra the Wiener filter is not optimal.
Another idea is to introduce a smoothness term in
our criterion.
2
We define smoothness by the quantity Qf
where Q is a high pass filter operator, e.g. the
Laplacian, (Q is a doubly block circulant matrix
representing convolution by the Laplacian).
2
We look for smooth solutions minimizing Qf

C. Nikou Digital Image Processing (E12)

46

Restoration in Presence of Noise


Constrained Least Squares Filter (cont...)

We have the following constrained least


squares (CLS) optimization problem:
2
Minimize Qf subject to Hf g
yielding the Lagrange multiplier minimization of
the function:
2

J (f , ) Hf g Qf
Data fidelity term

Smoothness term

C. Nikou Digital Image Processing (E12)

47

Restoration in Presence of Noise


Constrained Least Squares Filter (cont...)

J (f , ) 0 2HT (Hf g ) 2QT Qf 0


f
f H H Q Q H g
T

Parameter controls the degree of smothness:


0, f H H HT g
T

, f 0

pseudo-inverse, ultra rough solution

ultra smooth solution


C. Nikou Digital Image Processing (E12)

48

Restoration in Presence of Noise


Constrained Least Squares Filter (cont...)
In the Fourier domain, the constrained least
squares filter becomes:

F (k , l )

H * (k , l )
2

H (k , l ) Q(k , l )

G (k , l )

Keep always in mind to zero-pad the images


properly.
C. Nikou Digital Image Processing (E12)

49

Restoration in Presence of Noise


Constrained Least Squares Filter (cont...)

Low noise: Wiener and CLS generate equal results.


High noise: CLS outperforms Wiener if is properly selected.
It is easier to select the scalar value for than to approximate the SNR
which is seldom constant.
C. Nikou Digital Image Processing (E12)

50

Restoration Performance Measures

Original image f and restored image f


Mean square error (MSE):
1
MSE
MN

M 1 N 1

( m, n)

f
(
m
,
n
)

m 0 n 0

C. Nikou Digital Image Processing (E12)

51

Restoration Performance Measures


(cont...)

The Signal to Noise Ratio (SNR) considers the


difference between the two images as noise:
M 1 N 1

SNR

M 1 N 1

f (m, n) 2

m 0 n 0

( m, n)

f
(
m
,
n
)

m 0 n 0

C. Nikou Digital Image Processing (E12)

You might also like