digital image processing lectures 23 & 24 · 2011-04-21 · image restoration restoration...

23
Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter Digital Image Processing Lectures 23 & 24 M.R. Azimi, Professor Department of Electrical and Computer Engineering Colorado State University M.R. Azimi Digital Image Processing

Upload: others

Post on 16-Jul-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Digital Image Processing Lectures 23 & 24 · 2011-04-21 · Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter Digital Image Processing Lectures 23

Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter

Digital Image ProcessingLectures 23 & 24

M.R. Azimi, Professor

Department of Electrical and Computer EngineeringColorado State University

M.R. Azimi Digital Image Processing

Page 2: Digital Image Processing Lectures 23 & 24 · 2011-04-21 · Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter Digital Image Processing Lectures 23

Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter

Restoration Filters

There are basically two classes of restoration filters.

1 Deterministic-BasedThese methods ignore effects of noise and statistics of the image,e.g., inverse filter and Least Squares (LS) filter.

2 Stochastic-BasedStatistical information of the noise and image is used to generatethe restoration filters, e.g., 2-D Wiener filter and 2-D Kalman filter.

Inverse Filter(a) Direct Inverse Filter: Attempts to recover the original image from theobserved blurred image using an inverse system, hI(m,n), correspondingto the blur PSF, h(m,n).

Figure 1: Inverse Filtering.

M.R. Azimi Digital Image Processing

Page 3: Digital Image Processing Lectures 23 & 24 · 2011-04-21 · Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter Digital Image Processing Lectures 23

Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter

If we assume no noise case, we have

y(m,n) = h(m,n) ∗ ∗x(m,n)

Y (k, l) = H(k, l)X(k, l)

The inverse filter produces

x(m,n) = y(m,n) ∗ ∗hI(m,n)

X(k, l) = Y (k, l)HI(k, l)

Then,x(m,n) = x(m,n) ∗ ∗h(m,n) ∗ ∗hI(m,n)

orX(k, l) = X(k, l)H(k, l)HI(k, l)

Clearly, x(m,n) = x(m,n) or X(k, l) = X(k, l) iff HI(k, l) = 1H(k,l) or

h(m,n) ∗ ∗hI(m,n) = δ(m,n).Thus

X(k, l) = Y (k, l)/H(k, l)

Now, if there is a slight noise (e.g., quantization noise) in the image,

Y (k, l) = H(k, l)X(k, l) +N(k, l)

M.R. Azimi Digital Image Processing

Page 4: Digital Image Processing Lectures 23 & 24 · 2011-04-21 · Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter Digital Image Processing Lectures 23

Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter

The inverse filter gives

X(k, l) = X(k, l) +N(k, l)

H(k, l)

At those frequencies where H(k, l) ' 0, N(k,l)H(k,l) becomes very large i.e.

the noise is amplified.(b) Pseudo Inverse FilterTo overcome the problems with the direct inverse filter, modify thetransfer function of the inverse filter as

HI(k, l) =H∗(k, l)

|H(k, l)|2 + ε

where ε is a small positive quantity. For ε = 0, we haveHI(k, l) = 1

H(k,l) . Alternatively, we can use

H+(k, l) =

1H(k,l) |H(k, l)| ≥ ε0 |H(k, l)| < ε

While the first form of the pseudo inverse filter corresponds to a special

case of Wiener filter (discussed next) it does not take into account the

statistics of the noise and image.

M.R. Azimi Digital Image Processing

Page 5: Digital Image Processing Lectures 23 & 24 · 2011-04-21 · Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter Digital Image Processing Lectures 23

Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter

Example 1: Derive the transfer function of the LS filter and show that itis the same as the inverse filter.Solution: The LS solution minimizes the LS cost function,

J(x) =∑m

∑n

|y(m,n)− y(m,n)|2

where y(m,n) = h(m,n) ∗ ∗x(m,n) is an estimate of the observedimage based upon the LS estimate x(m,n). Using energy preservation,

J(x) = J(X) =1

N2

∑k

∑l

|Y (k, l)− Y (k, l)|2

where Y (k, l) = H(k, l)X(k, l). Taking derivative of J wrt X(k, l) gives

∂J

∂X(k, l)= 0 =⇒ −H∗(k, l)(Y (k, l)−H(k, l)X(k, l)) = 0

which gives the same inverse filter solution i.e.,

XLS(k, l) = Y (k, l)/H(k, l)

Quest ion: What would you change in the cost function to yield LSsolution that is the same as that of the pseudo inverse?

M.R. Azimi Digital Image Processing

Page 6: Digital Image Processing Lectures 23 & 24 · 2011-04-21 · Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter Digital Image Processing Lectures 23

Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter

Wiener Filter

This filter takes into account 1st and 2nd order statistics of the noise andimage to generate the restoration filter transfer function. Additionally, itprovides the best linear estimate of the image based up minimizing MSE(i.e. MMSE). However, it assumes wide-sense stationarity of the imagefield. We begin with the 1-D case.

1-D Wiener Filter:Goal: Find g(n)’s or FIR filter coefficients so that z(n) is as close aspossible to the desired signal d(n) by minimizing MSE J(g) = E[e2(n)].

Figure 2: Wiener Filtering Process.

M.R. Azimi Digital Image Processing

Page 7: Digital Image Processing Lectures 23 & 24 · 2011-04-21 · Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter Digital Image Processing Lectures 23

Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter

The MSE is given by

J(g(n)) = E[e2(n)]

with e(n) = d(n)− z(n)

z(n) = g(n) ∗ y(n) =

N∑i=0

g(i)y(n− i)

Then

J(g) = E[(d(n)−N∑i=0

g(i)y(n− i))2]

To find the optimum g(k)’s,

∂J(g)

∂g(k)= 0 =⇒ −2E[y(n− k)(d(n)−

N∑i=0

g(i)y(n− i))] = 0, k ∈ [0, N ]

Thus, we get

N∑i=0

g(i)E[y(n− i)y(n− k)] = E[d(n)y(n− k)]

M.R. Azimi Digital Image Processing

Page 8: Digital Image Processing Lectures 23 & 24 · 2011-04-21 · Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter Digital Image Processing Lectures 23

Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter

orN∑i=0

g(i)ryy(k − i) = rdy(k)

g(k) ∗ ryy(k) = rdy(k)

where rdy(k)∆= E[d(n)y(n− k)] is the cross-correlation between d(n)

and y(n) and ryy(k − i) ∆= E[y(n− i)y(n− k)] is the auto-correlation of

y(n).

Taking the DTFT gives the general expression for the Wiener filtertransfer function

G(ejΩ) =Sdy(ejΩ)

Syy(ejΩ)

where

Sdy(ejΩ) = DTFTrdy(k) Cross− power spectrum

Syy(ejΩ) = DTFTryy(k) Power spectrum

M.R. Azimi Digital Image Processing

Page 9: Digital Image Processing Lectures 23 & 24 · 2011-04-21 · Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter Digital Image Processing Lectures 23

Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter

Now, let d(n) = x(n) (during the training phase) then assuming that thenoise and signal are uncorrelated

y(n) = h(n) ∗ x(n) + η(n)

ryy(k) = y(k) ∗ y(−k)

= (h(k) ∗ x(k) + η(k))(h(−k) ∗ x(−k) + η(−k))

= h(k) ∗ h(−k) ∗ rxx(k) + rηη(k)

rdy(k) = d(k) ∗ y(−k)

= x(k) ∗ (h(−k) ∗ x(−k) + η(−k))

= h(−k) ∗ rxx(k)

Thus, we get

Syy(ejΩ) = |H(ejΩ)|2Sxx(ejΩ) + Sηη(ejΩ)

Sdy(ejΩ) = H∗(ejΩ)Sxx(ejΩ)

Hence leading to Wiener filter transfer function,

G(ejΩ) =H∗(ejΩ)Sxx(ejΩ)

|H(ejΩ)|2Sxx(ejΩ) + Sηη(ejΩ)

M.R. Azimi Digital Image Processing

Page 10: Digital Image Processing Lectures 23 & 24 · 2011-04-21 · Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter Digital Image Processing Lectures 23

Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter

Important Remarks

1 Once the transfer function of the Wiener filter is designed, thefiltering can simply be done as shown in Fig. 3.

Figure 3: Wiener Filter Transfer Function.

2 If h(n) = δ(n)→ H(ejΩ) = 1 i.e. signal plus noisey(n) = x(n) + η(n), the transfer function simplifies to

G(ejΩ) =Sxx(ejΩ)

Sxx(ejΩ) + Sηη(ejΩ)

In this case, the power spectrum of the noise and signal can bemeasured from the power spectrum of the observed signal as shownin Fig. 4 (note that for zero mean white Gaussian noiseSηη(ejΩ) = ση

2).

M.R. Azimi Digital Image Processing

Page 11: Digital Image Processing Lectures 23 & 24 · 2011-04-21 · Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter Digital Image Processing Lectures 23

Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter

Figure 4: Estimating Noise Power.

3 A more useful form of the Wiener filter for frequency domainimplementation is to work with the DFT instead of DTFT, in whichcase the transfer function becomes,

G(k) =H∗(k)Sxx(k)

|H(k)|2Sxx(k) + Sηη(k)

4 The general Wiener filter transfer function,

G(ejΩ) =Sdy(ejΩ)

Syy(ejΩ)or G(k) =

Sdy(k)

Syy(k)

can be applied to other types of observation models e.g.,multiplicative noise case (see next example).

M.R. Azimi Digital Image Processing

Page 12: Digital Image Processing Lectures 23 & 24 · 2011-04-21 · Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter Digital Image Processing Lectures 23

Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter

Example 2: Derive the transfer function of the Wiener filter for thefollowing observation model.

y(n) = γ(n)[h(n) ∗ x(n)] + η(n)

where γ(n) and η(n) are uncorrelated multiplicative and additive randomnoise with mean and correlations µγ and µη, and rγγ(k) and rηη(k),respectively.Solution: We use the result in Remark 4 to obtain G(ejΩ). Since γ(n),η(n) and x(n) are mutually independent, using the convolution infrequency domain, the auto-correlation and power spectrum of theobserved signal becomes

ryy(k) = y(k) ∗ y(−k)

= rγγ(k)[h(k) ∗ h(−k) ∗ rxx(k)] + rηη(k)

and Syy(ejΩ) = Sγγ(ejΩ) ∗ ∗[|H(ejΩ)|2Sxx(ejΩ)] + Sηη(ejΩ)

On the other hand, cross-correlation and cross-power spectrum ford(k) = x(k) become

M.R. Azimi Digital Image Processing

Page 13: Digital Image Processing Lectures 23 & 24 · 2011-04-21 · Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter Digital Image Processing Lectures 23

Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter

rdy(k) = d(k) ∗ y(−k)

= µγrxx(k) ∗ h(−k)

Sdy(ejΩ) = µγSxx(ejΩ)H∗(ejΩ)

Thus, the transfer function becomes

G(ejΩ) =µγH

∗(ejΩ)Sxx(ejΩ)

Sγγ(ejΩ) ∗ ∗[|H(ejΩ)|2Sxx(ejΩ)] + Sηη(ejΩ)

2-D Wiener Filter:2-D extension is straightforward leading to 2-D Wiener transfer function

G(k, l) =H∗(k, l)Sxx(k, l)

|H(k, l)|2Sxx(k, l) + Sηη(k, l)

where H(k, l) = 2−D DFTh(m,n), and Sxx(k, l) and Sηη(k, l) are

power spectra of the original image x(m,n) and additive noise, η(m,n),

respectively. The process is depicted in Fig.5.

M.R. Azimi Digital Image Processing

Page 14: Digital Image Processing Lectures 23 & 24 · 2011-04-21 · Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter Digital Image Processing Lectures 23

Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter

Figure 5: Image formation system and 2-D Wiener filtering.

Important Remarks1 The above transfer function can be written as

G(k, l) =H∗(k, l)

|H(k, l)|2 + Sηη(k, l)/Sxx(k, l)

where Sηη(k, l)/Sxx(k, l) > 0 is like ε in the pseudo inverse filter,but dependent on SNR. Thus, the Wiener filter does not have thesingularity problem of the inverse filter.

2 If Sηη >> Sxx, G(k, l) reduces to de-emphasize the noisyobservation at that frequency. Recall that we have the oppositeeffects in the inverse filter, i.e. Wiener filter does not haveill-conditioning problems.

M.R. Azimi Digital Image Processing

Page 15: Digital Image Processing Lectures 23 & 24 · 2011-04-21 · Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter Digital Image Processing Lectures 23

Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter

3 Assume no blur case, h(m,n) = δ(m,n)→ H(k, l) = 1, then

G(k, l) =Sxx(k, l)

Sxx(k, l) + Sηη(k, l)=

SNR(k, l)

SNR(k, l) + 1

where

SNR(k, l)∆=Sxx(k, l)

Sηη(k, l)

If SNR >> 1→ G(k, l) ≈ 1, i.e. all frequency components are inthe passband, while SNR << 1→ G(k, l) ≈ SNR(k, l), i.e. all suchfrequencies are attenuated in proportion to their SNR values. Thisshows the adaptive nature of the Wiener filter.

4 Since auto-correlation is real and even, Sxx and Sηη are also realand non-negative. Thus, the phase of G(k, l) is

ΦG = ΦH∗ = −ΦH

i.e. the phase of the inverse filter.5 The main drawback of Wiener filter is the assumption of WSS for

both image and noise. This is not obviously true for images. Asresult, the filtered images exhibit some edge smearing artifacts.

M.R. Azimi Digital Image Processing

Page 16: Digital Image Processing Lectures 23 & 24 · 2011-04-21 · Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter Digital Image Processing Lectures 23

Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter

Figs. 6(a)-(d) show original, blurred (motion blur size 5), blurred andnoisy (SNR=7 dB), and finally the Wiener filtered Baboon. Note: evensome of the whisker details are restored.

Original Image of Baboon Baboon with Blurring Applied

Baboon with Blurring and Noise Wiener Filter Result

Figure 6: Blurred and Noisy Baboon and Wiener Filter Results.

M.R. Azimi Digital Image Processing

Page 17: Digital Image Processing Lectures 23 & 24 · 2011-04-21 · Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter Digital Image Processing Lectures 23

Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter

Recursive Restoration & Kalman Filtering

Wiener filter assumes WSS of the image field which leads to smearing ofthe edges and subtle textural features. This can be circumvented byrecursive Kalman Filter (KF). KF requires:

1 1-D or 2-D AR/ARMA model representation of the image field andcovariance of the noise.

2 1-D or 2-D state and observation equations with states being imagepixels to estimate.

3 Recursive implementation of the filtering equations.

Remark: For WSS cases, KF becomes the same as Wiener filter.

Here, we discuss one type of recursive image restoration using Strip

Kalman Filter (Azimi-Sadjadi, IEEE Trans. CAS, June 1989).

M.R. Azimi Digital Image Processing

Page 18: Digital Image Processing Lectures 23 & 24 · 2011-04-21 · Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter Digital Image Processing Lectures 23

Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter

Strip Kalman Filter

Consider an image which is vector scanned horizontally in strips of widthW . Image is assumed to be represented by an M th order vector ARprocess with causal ROS as shown. Then,

z(k) = AT1 z(k − 1) + · · ·+ATMz(k −M) + e(k)

where z(k) is a vector of pixels of size W , e(k) is the driving noise vectorand Ais are model coefficient matrices of size W ×W . We assume thatE[e(k)] = 0 and E[e(k)eT (j)] = Reδ(k − j) with Re being thecovariance matrix of e(k).

Figure 7: Strip Kalman Filtering.

M.R. Azimi Digital Image Processing

Page 19: Digital Image Processing Lectures 23 & 24 · 2011-04-21 · Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter Digital Image Processing Lectures 23

Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter

Note that the model coefficient matrices can be identified using vectorYule-Walker equation. To see this let’s form covariance matrix of datafrom the vector AR model above. This gives

Rz(m) = E[z(k)zT (k−m)] = Rz(m−1)A1+· · ·+Rz(m−M)AM+Reδ(m)

which yields

Rz(0) RTz (1) · · · · · · RTz (M)Rz(1) Rz(0) · · · · · · RTz (M − 1)

......

. . ....

. . ....

Rz(M) Rz(M − 1) · · · · · · Rz(0)

IW−A1

...

...−AM

=

Re

0

0

...0

Here Rz(−m) = RTz (m). Solving this vector Yule Walker equation leadsto the parameter matrices for AR model. The sample data covariancematrices Rz(m) in this equation are estimated using the training images

and Rz(m) = 1N

∑N−1k=0 z(k)zT (k −m).

M.R. Azimi Digital Image Processing

Page 20: Digital Image Processing Lectures 23 & 24 · 2011-04-21 · Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter Digital Image Processing Lectures 23

Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter

Next, we form the state equation by defining the state vector (sizeWM × 1) as

x(k) = [zT (k)zT (k − 1) · · · zT (k −M + 1)]T

then state equation (in canonical form) is

x(k) = Fx(k − 1) +Ge(k)

where

F =

AT1 AT2 · · · · · · ATMIW 0 · · · · · · 0

......

. . ....

. . ....

0 0 · · · · · · IW

, G =

IW0

...

...0

Now, consider vector observation equation in which blur is modeled as anMA (or FIR) process with ROS limited to that of AR model, i.e.

y(k) = H0z(k) +H1z(k − 1) + · · ·+HM−1z(k −M + 1) + n(k)

M.R. Azimi Digital Image Processing

Page 21: Digital Image Processing Lectures 23 & 24 · 2011-04-21 · Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter Digital Image Processing Lectures 23

Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter

where y(k) is the observation vector and n(k) represents the additivenoise vector with E[n(k)] = 0 and E[n(k)nT (j)] = Rnδ(k − j) with Rn

being the covariance matrix of n(k). In vector form, the observationequation becomes

y(k) = Hx(k) + n(k)

where H = [H0 · · ·HM−1].

The aim of Kalman filter is to generate estimates of the state vector(image) recursively based upon all available observations i.e.x(k|k) = E[x(k)|Z(k)] where Z(k) = z(1), · · · , z(k) is a set of allobservations up to time k. Then, the Kalman filter equations in order are:

1 Initial Estimate: x(k|k − 1) = F x(k − 1|k − 1).

2 A priori Error Covariance Matrix:P (k|k − 1) = FP (k − 1|k − 1)FT +GReG

T whereP (k|k − 1) = E[(x(k)− x(k|k − 1))(x(k)− x(k|k − 1))T ].

3 Kalman Gain: K(k) = P (k|k − 1)HT [HP (k|k − 1)HT +Rn]−1.

M.R. Azimi Digital Image Processing

Page 22: Digital Image Processing Lectures 23 & 24 · 2011-04-21 · Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter Digital Image Processing Lectures 23

Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter

4 Update Estimate: x(k|k) = x(k|k− 1) +K(k)[y(k)−H x(k|k− 1)].

5 A posteriori Error Covariance Matrix:P (k|k) = [I −K(k)H]P (k|k − 1) whereP (k|k) = E[(x(k)− x(k|k))(x(k)− x(k|k))T ].

Important Remarks:

1 Initial conditions are x(0|0) = µx[1, · · · , 1]T and P (0|0) = Px(0)which is a measure of confidence in µx i.e. larger Px(0) for lesserconfidence.

2 KF is driven by the innovation process ξ(k) = y(k)−H x(k|k − 1).

3 Eqs. in steps 2, 3, and 5 can be iterated off-line until convergence isreached for K(k) (stationary case) and then K(k) is used on-line inthe state updating process.

4 Note that Kalman gain matrix decreases when either effects of Re

or Px(0) decrease or when Rn increases. When Re ≈ 0 then K(k)asymptotically approaches to zero and hence KF becomesindependent of observations (data saturation may occur).

M.R. Azimi Digital Image Processing

Page 23: Digital Image Processing Lectures 23 & 24 · 2011-04-21 · Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter Digital Image Processing Lectures 23

Image Restoration Restoration Filters Inverse Filters Wiener Filter Kalman Filter

Figs. 8(a) and (b) show the noisy (additive WGN) Baboon withSNRinput =-1.7 dB and strip KF processed Baboon withSNRoutput =2.83 dB (i.e. >4.5dB improvements). Vector AR(1) wasused with W = 64. Clearly, the results are impressive.

Noisy Baboon KF Processed Baboon.

Figure 8: Noisy Baboon and Strip Kalman Filter Results.

M.R. Azimi Digital Image Processing