image restoration - lecture 14 · image restoration restore an image that has been degraded in some...

33
Image restoration Lecture 14 Milan Gavrilovic [email protected] Centre for Image Analysis Uppsala University Computer Assisted Image Analysis 2009-05-08 M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 1 / 33

Upload: others

Post on 28-Sep-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Image restorationLecture 14

Milan [email protected]

Centre for Image AnalysisUppsala University

Computer Assisted Image Analysis2009-05-08

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 1 / 33

Page 2: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Today’s lecture

Notes on chalkboard: Some properties of 2D DFT (review ofsection 4.6 in Gonzales-Woods)What is FFT?Filters in the frequency domain (a retrospective view of L04 andLab1)

General concepts of image restoration (5.1 − 5.2 and 5.5 in GW)Periodic noise reduction by frequency domain filtering (5.4 in GW)Inverse and Wiener filtering (5.6 − 5.8 in GW)

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 2 / 33

Page 3: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

The Fast Fourier Transform (FFT)

Discrete Fourier Transform (DFT)

F(u) =1M

M−1∑x=0

f (x)e−j2πux/M for u = 0, 1, . . . , M − 1

Fast Fourier Transform is an efficient algorithm for computing the DFT.

For a 1-D signal:The ordinary DFT of M points require M2 operations(multiplications/additions).The FFT of M points require M log2 M operations.

The FFT algorithm is based on the so-called successive doublingmethod. Implementation of FFT in 2D is analogous to the 1D case.

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 3 / 33

Page 4: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Filtering in the Frequency Domain

The basics

1 Multiply the input image by (−1)x+y to center the transform.2 Compute F(u, v), the DFT of the image from (1).3 Multiply F(u, v) by a filter function H(u, v).4 Compute the inverse DFT of the result in (3).5 Obtain the real part of the result in (4).6 Multiply the result in (5) by (−1)x+y.

G(u, v) = H(u, v)F(u, v)

Element-by-element multiplication.

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 4 / 33

Page 5: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Ideal Lowpass Filters and "Ringing"

In the frequency domain, define a cut-off radius D0.

Ideal Lowpass Filter (ILPF)

H (u, v) ={

1 if D (u, v) ≤ D0;0 if D (u, v) > D0.

To find h(x, y):

1 Centering: H(u, v) ∗ (−1)u+v

2 Inverse Fourier transform3 Multiply real part by (−1)x+y

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 5 / 33

Page 6: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Ideal Lowpass Filters and "Ringing"

Properties of h(x, y):

1 It has a central dominant circular component (providing theblurring)

2 It has concentric circular components (rings) giving rise to theringing effect.

Example of h(x) from theinverse FT of a disc (ILPF)with radius 5.

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 6 / 33

Page 7: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Ideal Lowpass Filters and "Ringing"

Original image (top left) andfiltered images with ILPF ofradius 5, 15 and 30,removing 8, 5.4 and 3.6% ofthe total power.This type of artefacts arenot acceptable in e.g.medical imaging.

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 7 / 33

Page 8: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Reduce "Ringing" with Non-Ideal Lowpass Filters

Butterworth Lowpass Filter (BLPF)

H (u, v) =1

1 +(

D(u,v)D0

)2n

n is the order of the filterA high n will cause "ringing" (approaching ILPF)No sharp discontinuity

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 8 / 33

Page 9: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Butterworth Lowpass Filter

BLPF"ringing"effects fordifferentvalues of n.

In general, BLPFs of order 2 are a good compromise between effectivelowpass filtering and acceptable ringing characteristics.

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 9 / 33

Page 10: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Gaussian Lowpass Filter

Gaussian Lowpass Filter (GLPF)

H (u, v) = e−D2(u,v)

2D20

D0 is the standard deviation (σ), or the "spread" of the Gaussian.The inverse FT of a Gaussian is also a Gaussian, meaning aGaussian smoothing in the spatial domain.Guarantees no ringing.

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 10 / 33

Page 11: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Highpass Filters

Ideal Highpass Filter (IHPF)

H (u, v) ={

0 if D (u, v) ≤ D0;1 if D (u, v) > D0.

Butterworth Highpass Filter (BHPF)

H (u, v) = 1 − 1

1 +(

D(u,v)D0

)2n =1

1 +(

D0D(u,v)

)2n

Gaussian Highpass Filter (GHPF)

H (u, v) = 1 − e−D2(u,v)

2D20

Same ringing effect as for the lowpass filters.

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 11 / 33

Page 12: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Highpass Filters

Spatial repre-sentation ofdifferenthighpassfilters (ideal,ButterworthandGaussian).

Ringing effect noticeable in ideal and Butterworth filters.

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 12 / 33

Page 13: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

High-Frequency Emphasis Filtering

Hhfe (u, v) = a + b ∗ Hhp (u, v)

Result ofhigh-frequencyemphasis filtering(original, highpass;high-freq emphasis,histogramequalization).

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 13 / 33

Page 14: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Image Restoration

Restore an image that has been degraded in some way.Make a model of the degeneration process and use inversemethods.Image restoration is an objective method using a priori informationof the degradation.Compare with image processing which is a method to present theimage in a "better" way.

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 14 / 33

Page 15: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Model

f (x, y) is the original image.H represents the system that affects our image.n(x, y) is disturbance, e.g., noise or external contribution.Obtained degraded image g(x, y) = H(f (x, y)) + n(x, y).Possible defects in the imaging system causing degradation:

I Bad focusing.I Motion.I Non-linearity of the sensor.I Noise.I etc...

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 15 / 33

Page 16: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Image Restoration

Possible approaches:Inverse filtering.Try to model degradation effect.Use Fourier-domain methods and identify which frequencies arerelated to the degrading effect.

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 16 / 33

Page 17: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Mathematical Fundamentals - Convolution

Convolution of Two Continuous Functions

f (x, y)⊗ g (x, y) =∫ ∞

−∞

∫ ∞

−∞f (α, β) g (x − α, y − β) dαdβ

Convolution by the Impulse Function∫ ∞

−∞f (x) δ (x − x0) dx = f (x0)

Note: The sifting property (L13) can be represented as convolvingwith the impulse function.

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 17 / 33

Page 18: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Simplified Model

Assume a model without noise n.

g (x, y) = H [f (x, y)]

Assume that the operator H isI linear: H[k1f1(x, y) + k2f2(x, y)] = k1H[f1(x, y)] + k2H[f2(x, y)]I additive: H[f1(x, y) + f2(x, y)] = H[f1(x, y)] + H[f2(x, y)]I homogeneous: H[k1f1(x, y)] = k1H[f1(x, y)]I position invariant: H[f (x − α, y − β)] = g(x − α, y − β)

then, the following is true

g (x, y) =∫ ∞

−∞

∫ ∞

−∞f (α, β) H [δ (x − α, y − β)] dαdβ

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 18 / 33

Page 19: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Impulse Response

Impulse Response for Degradation Function H

h (x, α, y, β) = H [δ (x − α, y − β)]

In imaging systems the impulse response is called the pointspread function (PSF).PSF describes how a point is imaged.

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 19 / 33

Page 20: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Fredholm Integral

Fredholm Integral or Superposition Integral of the First Kind

g (x, y) =∫ ∞

−∞

∫ ∞

−∞f (α, β) h (x, α, y, β) dαdβ

The Fredholm integral says that if the impulse response is known,the response to any input signal can be calculated.

If degradation function, H, is position invariant, the integral isreduced to the convolution integral:

Fredholm Integral of Position Invariant Degradation Function

g (x, y) =∫ ∞

−∞

∫ ∞

−∞f (α, β) h (x − α, y − β) dαdβ

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 20 / 33

Page 21: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Point Spread Function

Single impulse signal.

Two impulse signals.

Output blurred by the PSF.

Output blurred by the PSF.

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 21 / 33

Page 22: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Fourier Methods

From Fourier Analysis:sinusoidal function in time (or spatial) domain of one variable

corresponds totwo impulse functions in Fourier domain.

Therefore,periodic noise in an image (i.e., repeated noise patterns) causespeaks in the FT of the image.by supressing these peaks and inverse transforming the image, arestored image is achieved.

(The last problem in computer exercise 1)

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 22 / 33

Page 23: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Fourier Domain Filters

Bandreject filters (ideal, Butterworth and Gaussian).

Notch filters (ideal, Butterworth and Gaussian).

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 23 / 33

Page 24: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Periodic Noise Reduction

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 24 / 33

Page 25: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Notch Filtering Example

Original image.

Fourier spectrum and it’s partremoved with notch filter.

Inverse transform of notchfiltered image and result ofnotch filtering.

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 25 / 33

Page 26: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Inverse Filtering

We can thus describe our model as g(x, y) = f (x, y)⊗ h(x, y).The Fourier transform gives

G (u, v) = F (u, v) · H (u, v) ⇔ F̂ (u, v) =G (u, v)H (u, v)

By modeling the degenerating effect (h) and dividing the FT of theimage by the FT of the model, we can get the FT of a restoredimage.If noise is present, we get g(x, y) = f (x, y)⊗ h(x, y) + n(x, y)and

F̂ (u, v) =G (u, v)H (u, v)

− N (u, v)H (u, v)

The inverse transform gives the restored image.The method is called inverse filtering.

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 26 / 33

Page 27: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Problems with Inverse Filtering

At deconvolution, the FT of the image is divided by the FT of thedegrading effect.

Problems:I Small values of H(u, v) can cause overflow (usually small at HF).I If noise is included, it can be dominating.

Solutions:I Perform division only in a limited part of the (u, v)-plane.I Use weights to limit the effect at division with small numbers.

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 27 / 33

Page 28: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Inverse Filtering Examples

Original image.

Degraded image.

Full filter.

Radius of 85.

Radius of 70.

Radius of 40.

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 28 / 33

Page 29: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Wiener Filtering

We consider images and noise as random processes.We try to find an estimate f̂ of the uncorrupted image f such thatthe mean square error is minimized.

e2 = E{(

f − f̂)2

}If we assume the following conditions

1 Noise and image are uncorrelated.2 One or the other has zero mean.3 Greylevels in the estimate are linear functions of the graylevels in

the degraded image....then the minimum of the error function (in the frequency domain) isgiven by

F̂ (u, v) =

[H∗ (u, v) Sf (u, v)

Sf (u, v) |H (u, v)|2 + Sη (u, v)

]G (u, v)

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 29 / 33

Page 30: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Wiener Filtering

The Wiener filter can be written in a simpler form

F̂ (u, v) =

1H (u, v)

|H (u, v)|2

|H (u, v)|2 + Sη(u,v)Sf (u,v)

G (u, v)

Note that if the noise is zero, the Wiener filter reduces to theinverse filter.The noise power spectrum is constant when dealing withspectrally white noise.Approximation frequently used

F̂ (u, v) =

[1

H (u, v)|H (u, v)|2

|H (u, v)|2 + K

]G (u, v)

K is adjusted interactively for best result.

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 30 / 33

Page 31: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Filter Comparison

See the original and degraded image in slide 30.

Full inverse. Limited inverse. Wiener filter.

Figure 5.29 - another comparison!

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 31 / 33

Page 32: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Drawback with Wiener Filtering

Drawback:Must know (or approximate) the power spectra of undegradedimage and noise.

Better choice:Constrained Least Squares Filter (CLSF).

I Need only knowledge of mean and variance of noise (apart fromdegradation function).

I Only one parameter, which can be iteratively computed foroptimality.

CLSF, section 5.9 in GW - non-mandatory reading assignment!

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 32 / 33

Page 33: Image restoration - Lecture 14 · Image Restoration Restore an image that has been degraded in some way. Make a model of the degeneration process and use inverse methods. Image restoration

Reading InstructionsChapters for next lecture

Chapter 7 in Gonzales-Woods (only briefly).

M. Gavrilovic (Uppsala University) L14 Image restoration 2009-05-08 33 / 33