chapter 05b image restoration (linear restoration)

51
University of Ioannina - Department of Computer Science Image Restoration and Reconstruction (Linear Restoration Methods) Christophoros Nikou [email protected] Digital Image Processing

Upload: -

Post on 15-Jan-2016

229 views

Category:

Documents


0 download

DESCRIPTION

Image Restoration for Image Processing

TRANSCRIPT

Page 1: Chapter 05b Image Restoration (Linear Restoration)

University of Ioannina - Department of Computer Science

Image Restoration and Reconstruction(Linear Restoration Methods)

Christophoros Nikou

[email protected]

Digital Image Processing

Page 2: Chapter 05b Image Restoration (Linear Restoration)

2

C. Nikou – Digital Image Processing (E12)

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

Page 3: Chapter 05b Image Restoration (Linear Restoration)

3

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.

Page 4: Chapter 05b Image Restoration (Linear Restoration)

4

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.

111

1

N

MNM

aa

t t

taa

t t

A

Page 5: Chapter 05b Image Restoration (Linear Restoration)

5

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.

1

T

N

f f ff

x x

xx

Page 6: Chapter 05b Image Restoration (Linear Restoration)

6

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.

1 1

1

1

N

M M

N

g g

x x

g g

x x

g

x

Page 7: Chapter 05b Image Restoration (Linear Restoration)

7

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.

It is the derivative of the scalar valued function bTx with respect to vector x.

T

b x b

x

Page 8: Chapter 05b Image Restoration (Linear Restoration)

8

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.

If A is symmetric:

T T

x Ax A A x

x

2T

x Ax Ax

x

Page 9: Chapter 05b Image Restoration (Linear Restoration)

9

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.

It may be proved using the previous properties.

22 T

Ax b A Ax bx

Page 10: Chapter 05b Image Restoration (Linear Restoration)

10

C. Nikou – Digital Image Processing (E12)

Linear, Position-Invariant Degradation

We now consider a degraded image to be modelled by:

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).

( , ) ( , ) ( , ) ( , )g x y h x y f x y x y

Page 11: Chapter 05b Image Restoration (Linear Restoration)

11

C. Nikou – Digital Image Processing (E12)

Linear, Position-Invariant Degradation (cont...)

In the Fourier domain:

where multiplication is element-wise.

In matrix-vector form:

where H is a doubly block circulant matrix and f,g, and η are vectors (lexicographic ordering).

( , ) ( , ) ( , ) ( , )G k l H k l F k l N k l

g = Hf + η

Page 12: Chapter 05b Image Restoration (Linear Restoration)

12

C. Nikou – Digital Image Processing (E12)

Linear, Position-Invariant Degradation (cont...)

If the degradation function is unknown the problem of simultaneously recovering f(x,y) and h(x,y) is called blind deconvolution.

g = Hf + η

( , ) ( , ) ( , ) ( , )g x y h x y f x y x y

( , ) ( , ) ( , ) ( , )G k l H k l F k l N k l

Page 13: Chapter 05b Image Restoration (Linear Restoration)

13

C. Nikou – Digital Image Processing (E12)

Linear Restoration

Using the imaging system

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

g = Hf + η

Page 14: Chapter 05b Image Restoration (Linear Restoration)

14

C. Nikou – Digital Image Processing (E12)

Restoration in Absence of NoiseThe Inverse Filter

When there is no noise:

an obvious solution would be to use the inverse filter:

yielding

g = Hf

-1P = H

ˆ -1 -1f = Pg = H g = H Hf = f

Page 15: Chapter 05b Image Restoration (Linear Restoration)

15

C. Nikou – Digital Image Processing (E12)

Restoration in Absence of NoiseThe Inverse Filter (cont...)

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:

ˆ -1f = H g

-1H = W ΛW

Page 16: Chapter 05b Image Restoration (Linear Restoration)

16

C. Nikou – Digital Image Processing (E12)

Restoration in Absence of NoiseThe Inverse Filter (cont...)

where

Therefore:

-1H = W ΛW

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

f̂ = Pg ˆ -1f = H g ˆ -1 -1f = (W ΛW) g

ˆ -1 -1f = W Λ Wg ˆ -1 -1Wf = WW Λ Wg

ˆ -1F = Λ G

Page 17: Chapter 05b Image Restoration (Linear Restoration)

17

C. Nikou – Digital Image Processing (E12)

Restoration in Absence of NoiseThe Inverse Filter (cont...)

Which is the vectorized form of the DFT of the image:

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

Problem: what happens if H(k,l) has zero values?

Cannot perform inverse filtering!

ˆ -1F = Λ G( , )ˆ ( , )( , )

G k lF k l

H k l =

Page 18: Chapter 05b Image Restoration (Linear Restoration)

18

C. Nikou – Digital Image Processing (E12)

Restoration in Absence of NoiseThe Pseudo-inverse Filter

A solution is to set:

which is a type of pseudo-inversion.

Notice that the signal cannot be restored at locations where H(k,l)=0.

( , ), ( , ) 0ˆ ( , )( , )

0 , ( , ) 0

G k lH k l

H k lF k l

H k l

=

Page 19: Chapter 05b Image Restoration (Linear Restoration)

19

C. Nikou – Digital Image Processing (E12)

Restoration in Absence of NoiseThe 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.

Page 20: Chapter 05b Image Restoration (Linear Restoration)

20

C. Nikou – Digital Image Processing (E12)

Restoration in Absence of NoiseThe Pseudo-inverse Filter (cont...)

This distance is expressed by the norm:

min ( )Jf

f 20

Hf - g

f

2 0T H Hf - g 2 2T T H Hf H g

1T T f H H H g

0J

f

2( )J f Hf - g

Page 21: Chapter 05b Image Restoration (Linear Restoration)

21

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseThe Inverse Filter

Recall the imaging model with spatially invariant degradation and noise

g = Hf + η

( , ) ( , ) ( , ) ( , )g x y h x y f x y x y

( , ) ( , ) ( , ) ( , )G k l H k l F k l N k l

Page 22: Chapter 05b Image Restoration (Linear Restoration)

22

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseThe Inverse Filter (cont...)

Applying the inverse filter in the Fourier domain:

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!).

( , ) ( , ) ( , ) ( , )G k l H k l F k l N k l

( , )ˆ ( , ) ( , ) ( , )

N k lF k l F k l

H k l

Page 23: Chapter 05b Image Restoration (Linear Restoration)

23

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseThe 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.

Page 24: Chapter 05b Image Restoration (Linear Restoration)

24

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseThe Inverse Filter (cont...)

Blurring degradation

Page 25: Chapter 05b Image Restoration (Linear Restoration)

25

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseThe Inverse Filter (cont...)Inverse filter with cut-off

Page 26: Chapter 05b Image Restoration (Linear Restoration)

26

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseWiener 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:

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

2

ˆˆmin ( )E f

f f

Page 27: Chapter 05b Image Restoration (Linear Restoration)

27

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseWiener Filter (cont...)

Recall also the definition of the correlation matrix between two vectors x and y:

We assume that the image and the noise are uncorrelated:

1 1 1 2 1

1 2

NT

N N N N

E x y E x y E x y

E

E x y E x y E x y

xyR xy

ηf fηR R 0

Page 28: Chapter 05b Image Restoration (Linear Restoration)

28

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseWiener Filter (cont...)

We are looking for the best estimate:

Let’s confine our estimate to be obtainable by a linear operator on the observation:

and the goal is to find the best matrix P.

2

ˆˆmin ( )E f

f f

ˆ f Pg

Page 29: Chapter 05b Image Restoration (Linear Restoration)

29

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseWiener Filter (cont...)

Denoting by the n-th row of P:

2 22ˆ ˆ ˆ( ) ( )J E E E f f f f f f Pg

2 2ˆ( ) T Tn n n n

n n

J E E f f p g f p g

Tnp

Page 30: Chapter 05b Image Restoration (Linear Restoration)

30

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseWiener Filter (cont...)

ˆ( )TT T

n n n nn

J E f f p g f p g

T T T T T Tn n n n n n n n

n

E f f p gf f g p p gg p

T T T T T Tn n n n n n n n

n

E E E E f f p gf f g p p gg p

2n n n

T Tn n n

n

f f gf ggR p R p R p

Page 31: Chapter 05b Image Restoration (Linear Restoration)

31

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseWiener Filter (cont...)

We can now minimize the sum with respect to each term:

2 0n n n

T Tn n n

n

f f gf ggR p R p R pp

2 2 0n n gf ggR R p 1

nn gg gfp R R

1

n

Tn

f g ggp R R

Page 32: Chapter 05b Image Restoration (Linear Restoration)

32

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseWiener Filter (cont...)

Assembling the rows together:

We have to compute the two matrices:

1 fg ggP R R

( )( )T TE E ggR gg Hf η Hf η

T T T T T TE Hff H Hfη ηf H η η

T T ff fη ηf ηηHR H HR R H R

Page 33: Chapter 05b Image Restoration (Linear Restoration)

33

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseWiener Filter (cont...)

Assumming noise is uncorrelated with image:

Also,

Finally the matrix we are looking for is

( ) ...T T TE E fg ffR fg f Hf η R H

T gg ff ηηR HR H R

11 T T fg gg ff ff ηηP R R R H HR H R

Page 34: Chapter 05b Image Restoration (Linear Restoration)

34

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseWiener Filter (cont...)

The estimated uncorrupted image is

which may be also expressed as

This result is known as the Wiener filter or the minimum mean square error (MMSE) filter.

ˆ f Pg 1ˆ T T ff ff ηηf R H HR H R g

11 1 1ˆ T T ηη ff ηηf H R H R H R g

Page 35: Chapter 05b Image Restoration (Linear Restoration)

35

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseWiener Filter (cont...)

Special cases:

No blur (H=I, g=f+η):

No noise (Rηη=0, g=Ηf):

This is the inverse filter.

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

Do nothing on the observation.

1ˆ ff ff ηηf R R R g

1ˆ f Η g

ˆ f g

Page 36: Chapter 05b Image Restoration (Linear Restoration)

36

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseWiener 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.

Page 37: Chapter 05b Image Restoration (Linear Restoration)

37

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseWiener Filter (cont...)

Reminder: the inverse DFT complex exponential matrix diagonalizes any circulant matrix:

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

and that

1 HH W Λ W

T W W

1 1T W W

Page 38: Chapter 05b Image Restoration (Linear Restoration)

38

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseWiener Filter (cont...)

We will employ the following relations:

If H is real:

1 HH W Λ W

1 1TT H HH W Λ W WΛ W

* * *1 * * 1T T H HH H WΛ W W Λ W

1 * 1 *1( )N

N H HW Λ W W Λ W

Page 39: Chapter 05b Image Restoration (Linear Restoration)

39

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseWiener Filter (cont...)

The Wiener solution is now transformed to the Fourier domain:

Notice that the matrices are diagonal.

1ˆ T T ff ff ηηf R H HR H R g

11 1 * 1 1 1 * 1( )( ) ( )( )( ) ( ) ff H H ff H ηηW Λ W W Λ W W Λ W W Λ W W Λ W W Λ W g

11 * 1 *( ) ff H H ff H ηηW Λ Λ W W Λ Λ Λ Λ g

* * 1ˆ ( ) ff H H ff H ηηWf Λ Λ Λ Λ Λ Λ Wg

Page 40: Chapter 05b Image Restoration (Linear Restoration)

40

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseWiener Filter (cont...)

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).

* * 1ˆ ( ) ff H H ff H ηηWf Λ Λ Λ Λ Λ Λ Wg

*

2

( , ) ( , )( , ) ( , )

( , ) ( , ) ( , )

ff

ff

S k l H k lF k l G k l

S k l H k l S k l

Page 41: Chapter 05b Image Restoration (Linear Restoration)

41

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseWiener Filter (cont...)

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

and the Wiener filter becomes:

( , )SNR( , )

( , )ffS k l

k lS k l

*

2 -1

( , )( , ) ( , )

( , ) SNR ( , )

H k lF k l G k l

H k l k l

Page 42: Chapter 05b Image Restoration (Linear Restoration)

42

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseWiener Filter (cont...)

A well known estimate of Sff (k,l) is the periodogram (the ML estimate of Rff when f ia assumed Gaussian):

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

21( , ) ( , )ffS k l F k l

MN

21ˆ ( , ) ( , )ffS k l G k lMN

Page 43: Chapter 05b Image Restoration (Linear Restoration)

43

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseWiener Filter (cont...)

Page 44: Chapter 05b Image Restoration (Linear Restoration)

44

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseWiener Filter (cont...)

Inverse WienerDegraded image

Noise variance one order of magnitude less.

Noise variance ten orders of magnitude less.

Page 45: Chapter 05b Image Restoration (Linear Restoration)

45

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseConstrained 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.

We define smoothness by the quantity

where Q is a high pass filter operator, e.g. the Laplacian, (Q is a doubly block circulant matrix representing convolution by the Laplacian).

We look for smooth solutions minimizing

2Qf

2Qf

Page 46: Chapter 05b Image Restoration (Linear Restoration)

46

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseConstrained Least Squares Filter (cont...)

We have the following constrained least squares (CLS) optimization problem:

Minimize subject to

yielding the Lagrange multiplier minimization of the function:

2 2( , )J f Hf g Qf

Smoothness termData fidelity term

2Qf Hf g

Page 47: Chapter 05b Image Restoration (Linear Restoration)

47

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseConstrained Least Squares Filter (cont...)

2 ( ) 2 0T T H Hf g Q Qf( , ) 0J

f

f

1T T T

f H H Q Q H g

Parameter λ controls the degree of smothness:

10, T T

f H H H g pseudo-inverse, ultra rough solution

, 0 f ultra smooth solution

Page 48: Chapter 05b Image Restoration (Linear Restoration)

48

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseConstrained Least Squares Filter (cont...)

In the Fourier domain, the constrained least squares filter becomes:

Keep always in mind to zero-pad the images properly.

*

2 2

( , )( , ) ( , )

( , ) ( , )

H k lF k l G k l

H k l Q k l

Page 49: Chapter 05b Image Restoration (Linear Restoration)

49

C. Nikou – Digital Image Processing (E12)

Restoration in Presence of NoiseConstrained 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.

Page 50: Chapter 05b Image Restoration (Linear Restoration)

50

C. Nikou – Digital Image Processing (E12)

Restoration Performance Measures

Mean square error (MSE):

1 1 2

0 0

1 ˆMSE ( , ) ( , )M N

m n

f m n f m nMN

Original image f and restored image f̂

Page 51: Chapter 05b Image Restoration (Linear Restoration)

51

C. Nikou – Digital Image Processing (E12)

Restoration Performance Measures (cont...)

The Signal to Noise Ratio (SNR) considers the difference between the two images as noise:

1 12

0 01 1 2

0 0

ˆ ( , )SNR

ˆ( , ) ( , )

M N

m nM N

m n

f m n

f m n f m n