You are on page 1of 73

Digital Image Processing, 2nd ed.

www.imageprocessingbook.com

Chapter 5
Image Restoration

• 5.1 A mode of the Image Degradation/
Restoration Process
• Given g(x,y), some knowledge the degradation
about the degradation function H, and some
knowledge about the additive noise term η ( x, y ),
the objective
of
restoration
is
to
obtain
an

estimate f ( x, y ) of original image.

© 2002 R. C. Gonzalez & R. E. Woods

η

Digital Image Processing, 2nd ed.

www.imageprocessingbook.com

• We want the estimate to be as close as possible
to the original input image and, in general,∧ the
more we know about H and η ,the closer f ( x, y )
will be to f ( x, y )
• The degraded image is given in the spatial
domain by
g ( x , y ) = h ( x, y ) ∗ f ( x, y ) + η ( x, y )

© 2002 R. C. Gonzalez & R. E. Woods

(5.1 − 1)

Digital Image Processing, 2nd ed.

www.imageprocessingbook.com

• Where h( x, y ) the spatial representation of the
degradation function ,the symbol "*" indicates
spatial convolution.
• we may write the model in Eq(5.1-1) in an
equivalent frequency domain representation:
G (u , v) = H (u , v) F (u , v) + N (u , v) (5.1 − 2)

© 2002 R. C. Gonzalez & R. E. Woods

Digital Image Processing. 2nd ed. © 2002 R. Woods www.imageprocessingbook. E. Gonzalez & R.com . C.

2. © 2002 R. www. Woods .2 Noise Models • 5. Gonzalez & R.Digital Image Processing. E.1 Spatial and Frequency Properties of Noise • When the Fourier spectrum of noise is constant.com 5. 2 Some Important Noise Probability Density Function • Gaussian noise • Gaussian (also called normal).imageprocessingbook. noise models are used frequently in practice. the noise usually is called white noise. • 5. C. 2nd ed.2.

E. ( μ + σ )⎤⎦ . • Approximately 70% of its values will be in the range ⎡⎣( μ − σ ) . www. μ is the mean of average value of z .Digital Image Processing. Woods . C. ( μ + 2σ )⎤⎦ © 2002 R.z.imageprocessingbook. is given by 1 − ( z − μ )2 / 2σ 2 P( z ) = e (5.2 − 1) 2πσ • Where z represents gray level. Gonzalez & R. 2nd ed.com • The PDF of a Gaussian random variable.and about 95 % will be in the range ⎡⎣( μ − 2σ ) .and σ is its standard deviation.

2 − 4 ) 2 = πb/4 b(4 − π ) 4 • The Rayleigh density can be quite useful for approximating skewed histograms.imageprocessingbook. © 2002 R. Woods .2 − 3) σ (5 . C. www.com • Rayleigh noise • The PDF of Rayleigh noise is given by 2 ⎧2 −( z −a) / b ⎪ ( z − a)e p( z) = ⎨b ⎪⎩ 0 for z ≥ a (5.Digital Image Processing.2 − 2) for z < a • The mean and variance of this density are given by μ = a+ (5 . 2nd ed. Gonzalez & R. E.

2nd ed. E. Woods for z ≥ 0 for z < 0 (5. www. C. Gonzalez & R.Digital Image Processing.2 − 5) .com • Erlang (Gamma) noise • The PDF of Erlang noise is given by ⎧ a b z b −1 − az e ⎪ p ( z ) = ⎨ (b − 1)! ⎪ 0 ⎩ © 2002 R.imageprocessingbook.

2nd ed. C.imageprocessingbook. E.Digital Image Processing. Woods www.com . Chapter 5 Image Restoration © 2002 R. Gonzalez & R.

2nd ed. E. Woods if a ≤ z ≤ b otherwise (5. www.com • Exponential noise • The PDF of exponential noise is given by ⎧ae − az p( z ) = ⎨ ⎩ 0 for z ≥ 0 for z < 0 (5. Gonzalez & R.2 − 11) .2 − 8) • Uniform noise • The PDF of uniform noise is given by ⎧ 1 ⎪ p(z) = ⎨ b − a ⎪⎩ 0 © 2002 R.imageprocessingbook.Digital Image Processing. C.

2nd ed.imageprocessingbook. www. Woods for z = a for z = b otherwise (5.Digital Image Processing. C.2 − 14) . E. Gonzalez & R.com • Impulse (salt-and-pepper) noise • The PDF of (bipolar) impulse noise is given by ⎧ Pa ⎪ p( z ) = ⎨ Pb ⎪0 ⎩ © 2002 R.

www.Digital Image Processing. 2nd ed. • Impulse noise generally is digitized as extreme (pure black or white) values in an image. Woods . C.imageprocessingbook.com • Impulse noise values will resemble salt-andpepper granules randomly distributed over the image. E. © 2002 R. Gonzalez & R.

imageprocessingbook. Gonzalez & R. E.Digital Image Processing. Chapter 5 Image Restoration © 2002 R.com . 2nd ed. C. Woods www.

Digital Image Processing. Woods . 2nd ed.3 Periodic Noise • Periodic Noise in an image irises typically from electrical or electromechanical interference during image acquisition. Gonzalez & R. www. C.imageprocessingbook.com • 5. © 2002 R. E. This is the only type of spatially dependent noise that will be considered in this chapter. • The Fourier transform of a pure sinusoid is a pair of conjugate impulses located at the conjugate frequencies of the sine wave . • Periodic noise can be reduced significantly via frequency domain filtering.2.

• As noted in the previous section.com • 5. © 2002 R. E.Digital Image Processing. C. Woods . 2nd ed.2.4 Estimation of Noise Parameters • The parameters of periodic noise typically are estimated by inspection of the Fourier spectrum of the image. periodic noise tends to produce frequency spikes that often can be detected even by visual analysis.imageprocessingbook. Gonzalez & R. www.

C.imageprocessingbook. Chapter 5 Image Restoration © 2002 R. E.Digital Image Processing. Woods www.com . 2nd ed. Gonzalez & R.

C. Gonzalez & R.imageprocessingbook.Digital Image Processing. Chapter 5 Image Restoration © 2002 R. 2nd ed.com . E. Woods www.

• For the other shapes discussed in Section 5.imageprocessingbook. μ = ∑ zi p ( zi ) www.Digital Image Processing. E.2 − 16) zi ∈S • If the shape is approximately Gaussian .then the mean and variance is all we need because the Gaussian PDF is completely specified by these two parameters .2.2. Gonzalez & R.2 − 15) zi ∈S σ = ∑ ( zi − μ ) p ( zi ) 2 2 (5.we use the mean and variance to solve for the parameters a and b. Woods .com (5. C. © 2002 R. 2nd ed.

Gonzalez & R. C. E. 2nd ed. Chapter 5 Image Restoration © 2002 R.com .Digital Image Processing.imageprocessingbook. Woods www.

Digital Image Processing. E.imageprocessingbook. 2nd ed. www.3 Restoration in the Presence of Noise OnlySpatial Filtering • Spatial filtering is the method of choice in situations when only additive noise is present. Gonzalez & R.com • 5. Woods . © 2002 R. C.

com .Digital Image Processing.imageprocessingbook. C. Gonzalez & R. Chapter 5 Image Restoration © 2002 R. Woods www. E. 2nd ed.

© 2002 R. Gonzalez & R.t )∈S xy (5.Digital Image Processing.com • 5. Woods .1 Mean Filters • Arithmetic mean filter ∧ 1 f ( x. C.imageprocessingbook. Noise is reduced as a result of blurring.3. E. www. 2nd ed. t ) ∑ mn ( s . y ) = g ( s.3 − 3) • A mean filter simply smoothes local variations in an image.

2nd ed. Gonzalez & R.com • Geometric mean filter ⎡ ⎤ f ( x.imageprocessingbook. but it tends to lose less image detail in the process. © 2002 R.Digital Image Processing. C. Woods .t )∈S xy ⎥⎦ ∧ 1 mn (5. t ) ⎥⎥ ⎢⎣ ( s . www. y ) = ⎢⎢ ∏ g ( s. E.3 − 4) • A geometric mean filter achieves smoothing comparable to the arithmetic mean filter.

t )∈S xy 1 g ( s. © 2002 R. Gonzalez & R. It does well also with other types of noise like Gaussian noise.com • Harmonic mean filter ∧ f ( x. www.imageprocessingbook. Woods .3 − 5) • The harmonic mean filter works well for salt noise.Digital Image Processing. E. C. but fails for pepper noise. y ) = mn ∑ ( s . t ) (5. 2nd ed.

For negative values of Q it eliminates salt noise.3 − 6) • where Q is called the order of the filter.Digital Image Processing. E. This filter is well suited for reducing or virtually eliminating the effects of salt-and-pepper noise. Gonzalez & R.imageprocessingbook. www.com • Contraharmonic mean filter ∧ f ( x. C. • For positive values of Q. It cannot do both simultaneously. t )Q +1 ( s .t )∈S xy ∑ ( s . the filter eliminates pepper noise. Woods . © 2002 R. t ) Q (5.t )∈S xy g ( s. 2nd ed. y ) = ∑ g ( s.

Digital Image Processing, 2nd ed.

Chapter 5
Image Restoration

© 2002 R. C. Gonzalez & R. E. Woods

www.imageprocessingbook.com

Digital Image Processing, 2nd ed.

www.imageprocessingbook.com

• 5.3.2 Order-Statistics Filters
• Median filter

f ( x, y ) = median { g ( s, t )}
( s ,t )∈S xy

(5.3 − 7)

• Certain types of random noise, they provide excellent
noise-reduction capabilities, with considerably less
blurring than linear smoothing filters .
• Median filters are particularly effective in the
presence of both bipolar and unipolar impulse noise.

© 2002 R. C. Gonzalez & R. E. Woods

Digital Image Processing, 2nd ed.

Chapter 5
Image Restoration

© 2002 R. C. Gonzalez & R. E. Woods

www.imageprocessingbook.com

t )} ( s . 2nd ed.com • Max and min filters ∧ f ( x. ∧ f ( x. Woods . y ) = max { g ( s.3 − 9) • This filter is useful for finding the darkest points in an image. E.imageprocessingbook.t )∈S xy (5.Digital Image Processing.3 − 8) • This filter is useful for finding the brightest points in an image. © 2002 R. y ) = min { g ( s. t )} ( s . C.t )∈S xy (5. Gonzalez & R. www.

C. 2nd ed.Digital Image Processing. Woods www.imageprocessingbook. Chapter 5 Image Restoration © 2002 R.com . E. Gonzalez & R.

Digital Image Processing. t )}⎥ ( s .imageprocessingbook. Gonzalez & R. 2nd ed.3 − 10) • This filter works best for randomly distributed noise. t )} + min { g ( s.t )∈S xy 2 ⎣ ( s . Woods . E.t )∈S xy ⎦ ∧ (5. www.com • Midpoint filter 1⎡ ⎤ f ( x. like Gaussian or uniform noise. C. © 2002 R. y ) = ⎢ max { g ( s.

Gonzalez & R. Woods ∑ ( s .imageprocessingbook. t ) in the neighborhood Sxy .com • Alpha-trimmed mean filter • Suppose that we delete the d/2 lowest and the d/2 highest gray-level values of g ( s. t ) (5. 2nd ed. y ) = mn − d © 2002 R. E. C.t )∈S xy g r ( s.Digital Image Processing. www. • A filter formed by averaging these remaining pixels is called an alpha-trimmed mean filter: ∧ 1 f ( x.3 − 11) .

C.Digital Image Processing. Woods .com • The alpha-trimmed filter is useful in situations involving multiple types of noise. E. © 2002 R. such as a combination of salt-and-pepper and Gaussian noise.imageprocessingbook. 2nd ed. www. Gonzalez & R.

C.Digital Image Processing. Chapter 5 Image Restoration © 2002 R.com .imageprocessingbook. Gonzalez & R. E. 2nd ed. Woods www.

com . E. 2nd ed.imageprocessingbook. Chapter 5 Image Restoration © 2002 R. Gonzalez & R.Digital Image Processing. C. Woods www.

C. 2 © 2002 R.Digital Image Processing.If the local variance is high relative toσ η . www. A high local variance typically is associated with edges. y).y). Gonzalez & R. 2nd ed.3 Adaptive Filters • Adaptive local noise reduction filter 1.3. E.y) is equal to f(x. If σ is zero. zero-noise case in which g(x. 2.imageprocessingbook. the filter should return simply the 2 η value of g(x.com 5. the filter should return a value close to g(x. Woods . This is the trivial. and these should be preserved.y).

and local noise is to be reduced simply by averaging σ η2 f ( x. If the two variances are equal.imageprocessingbook. y ) − 2 [ g ( x. E. y ) = g ( x. Gonzalez & R. we want the filter to return the arithmetic mean value of the pixels in S xy . C. www. This condition occurs when the local area has the same properties as the overall image.Digital Image Processing. Woods (5.com 3. y ) − mL ] σL ∧ © 2002 R.3 − 12) . 2nd ed.

Digital Image Processing. Gonzalez & R. Chapter 5 Image Restoration © 2002 R. 2nd ed.com . Woods www. E.imageprocessingbook. C.

com . 2nd ed. E. Gonzalez & R.Digital Image Processing. Woods www. Chapter 5 Image Restoration © 2002 R. C.imageprocessingbook.

2nd ed. Gonzalez & R. Woods www. y) Smax = maximum allowed size of Sxy. © 2002 R.Digital Image Processing. C.com . E. • Adaptive median filter • • • • • zmin = minimum gray level value in Sxy zmax = maximum gray level value in Sxy zmed = median of gray levels in Sxy zxy = gray level at coordinates (x.imageprocessingbook.

Woods www. Gonzalez & R.com .imageprocessingbook.Digital Image Processing. • Level A: A1 = zmed − zmin A2 = zmed − zmax If Al > 0 AND A2 < 0. E. Go to level B Else increase the window size If window size ≤ Smax repeat level A Else output Zxy © 2002 R. 2nd ed. C.

Gonzalez & R. • Level B: B1 = z xy − zmin B 2 = z xy − zmax If Bl > 0 AND B2 < 0. C.com .Digital Image Processing.imageprocessingbook. Woods www. E. 2nd ed. output zxy Else output Zmed © 2002 R.

2nd ed. and to reduce distortion.com • The key to understanding the mechanics of this algorithm is to keep in mind that it has three main purposes: to remove salt-and-pepper (impulse) noise. Gonzalez & R. www.Digital Image Processing. such as excessive thinning or thickening of object boundaries. C. to provide smoothing of other noise that may not be impulsive. Woods .imageprocessingbook. E. © 2002 R.

com . Woods www.imageprocessingbook.Digital Image Processing. E. 2nd ed. Gonzalez & R. Chapter 5 Image Restoration © 2002 R. C.

2nd ed. v) < D0 + 2 2 ⎪ w ⎪ if D u v D > − 1 ( . v) = ⎨0 if D0 − ≤ D(u .Digital Image Processing. v) is the distance from the origin of the centered frequency rectangle.com 5. www. ) 0 ⎪ 2 ⎩ (5. Woods . W is the width of the band. and D0 is its radial center. ) 0 ⎪ 2 ⎪ w w ⎪ H (u .3-3).4 Periodic Noise Reduction by Frequency Domain Filtering • 5. E. w ⎧ < − if D u v D 1 ( .(4. as given in Eq.imageprocessingbook.4 − 1) • where D (u. Gonzalez & R.1 Bandreject Filters • Bandreject filters remove or attenuate a band of frequencies about the origin of the Fourier transform.4. © 2002 R. C.

C. v ) − D02 ⎤ − ⎢ ⎥ 2 ⎢⎣ D ( u .Digital Image Processing. v ) w ⎤ 1+ ⎢ 2 2 ⎥ ( .com • A Butterworth bandreject filter of order n 1 H (u . www.4 − 2) • Gaussian bandreject filter is given by H (u .imageprocessingbook. v ) = ⎡ D (u . v ) w ⎥⎦ (5. E. 2nd ed. ) D u v D − 0 ⎦ ⎣ (5. Gonzalez & R. Woods 1 ⎡ D 2 ( u . v) = 1 − e © 2002 R.4 − 3) .

E. C.imageprocessingbook. Chapter 5 Image Restoration © 2002 R.Digital Image Processing. Woods www. Gonzalez & R. 2nd ed.com .

C.com • A good example is an image corrupted by additive periodic noise that can be approximated as two-dimensional sinusoidal functions. www. Gonzalez & R. E.imageprocessingbook. © 2002 R. 2nd ed. Woods .Digital Image Processing.

E. Gonzalez & R. C.Digital Image Processing. Woods www.imageprocessingbook. 2nd ed.com . Chapter 5 Image Restoration © 2002 R.

Digital Image Processing. 2nd ed.3 Notch Filters • A notch filter rejects (or passes) frequencies in predefined neighborhoods about a center frequency.imageprocessingbook.2 Bandpass Filters H bp (u .4. v) (5.com • 5. v) = 1 − H br (u . Figure 5. Woods . Butterworth. © 2002 R. Gonzalez & R. E. C. an Gaussian notch (reject) filters.18 shows 3-D plots of ideal.4. www.4 − 4) • 5.

Gonzalez & R. Woods www. 2nd ed. C. E.com . Chapter 5 Image Restoration © 2002 R.Digital Image Processing.imageprocessingbook.

Woods www.Digital Image Processing. C. 2nd ed. Gonzalez & R.imageprocessingbook. E. Chapter 5 Image Restoration © 2002 R.com .

com .Digital Image Processing. Gonzalez & R. E. Woods www. C. Chapter 5 Image Restoration © 2002 R. 2nd ed.imageprocessingbook.

Woods www.Digital Image Processing.com . Gonzalez & R. Chapter 5 Image Restoration © 2002 R. C.imageprocessingbook. E. 2nd ed.

com .Digital Image Processing. Gonzalez & R. Chapter 5 Image Restoration © 2002 R. 2nd ed. C. Woods www.imageprocessingbook. E.

2nd ed.imageprocessingbook. Woods www.Digital Image Processing.com . E. C. Gonzalez & R. Chapter 5 Image Restoration © 2002 R.

Gonzalez & R. C.com . Woods www.Digital Image Processing. 2nd ed.imageprocessingbook. E. Chapter 5 Image Restoration © 2002 R.

Gonzalez & R. Chapter 5 Image Restoration © 2002 R.com .imageprocessingbook.Digital Image Processing. Woods www. C. 2nd ed. E.

com . Woods www. Gonzalez & R. 2nd ed.Digital Image Processing. Chapter 5 Image Restoration © 2002 R. C.imageprocessingbook. E.

Chapter 5 Image Restoration © 2002 R. Woods www. E.imageprocessingbook. Gonzalez & R. C.com .Digital Image Processing. 2nd ed.

E.Digital Image Processing.imageprocessingbook. Chapter 5 Image Restoration © 2002 R.com . C. 2nd ed. Gonzalez & R. Woods www.

v) = ⎢ ⎥ G (u. v) + Sη (u . v) / S f (u .Digital Image Processing. v) 2 ⎢⎣ H (u . v) F (u. v) ⎥⎦ ∧ © 2002 R. v) 2 ⎢⎣ H (u. Woods . v) / S f (u . v) ⎥⎦ ⎡ ⎤ H ∗ (u .imageprocessingbook. v) + Sη (u. v) + Sη (u . v) H (u . v) =⎢ ⎥ G (u . v) ⎥⎦ 2 ⎡ 1 ⎤ H (u .8 − 2) =⎢ ⎥ G (u . E.8 − 1) ⎡ ⎤ H ∗ (u . v) (5. Gonzalez & R. www.com 5. 2nd ed. v) 2 ⎢⎣ S f (u .8 Minimum Mean Square Error (Wiener) Filtering 2 ∧ ⎧ ⎪⎛ ⎞ ⎫⎪ 2 e = E ⎨⎜ f − f ⎟ ⎬ ⎠ ⎪⎭ ⎪⎩ ⎝ (5 . v) S f (u . v) H (u. C.

com (5. v) H (u . v) ⎤ F (u . v) = ⎢ ⎥ G (u . E. Woods www. Gonzalez & R. 2 ⎡ 1 H (u.imageprocessingbook.8 − 3) . v) 2 ⎢⎣ H (u . C. 2nd ed.Digital Image Processing. v) + k ⎥⎦ ∧ © 2002 R.

Chapter 5 Image Restoration © 2002 R. 2nd ed.com . E. Woods www. C.Digital Image Processing.imageprocessingbook. Gonzalez & R.

Gonzalez & R. E. C. Chapter 5 Image Restoration © 2002 R. Woods www.imageprocessingbook.Digital Image Processing. 2nd ed.com .

2nd ed.com . Gonzalez & R.imageprocessingbook.Digital Image Processing. E. Chapter 5 Image Restoration © 2002 R. Woods www. C.

Digital Image Processing. Gonzalez & R. E. Woods www.imageprocessingbook.com . 2nd ed. Chapter 5 Image Restoration © 2002 R. C.

y ) (5. C. y ) (5.11.1 Spatial Transformations x = r ( x.11 Geometric Transformations • 5. E. www.imageprocessingbook. Gonzalez & R. Woods .Digital Image Processing. 2nd ed.com 5.11 − 1) y = s ( x.11 − 2) ' ' © 2002 R.

y ) = c5 x + c6 y + c7 xy + c8 (5.11 − 4) x = c1 x + c2 y + c3 xy + c4 (5. Woods . C. www.11 − 3) s ( x. 2nd ed.11 − 5) y = c5 x + c6 y + c7 xy + c8 (5. Gonzalez & R.imageprocessingbook. E. y ) = c1 x + c2 y + c3 xy + c4 (5.com r ( x.11 − 6) ' ' © 2002 R.Digital Image Processing.

Gonzalez & R.com . Woods www.Digital Image Processing. 2nd ed. E. C.imageprocessingbook. Chapter 5 Image Restoration © 2002 R.

Chapter 5 Image Restoration © 2002 R. C. Gonzalez & R. E.imageprocessingbook. Woods www.com . 2nd ed.Digital Image Processing.

C.imageprocessingbook. Chapter 5 Image Restoration © 2002 R. 2nd ed. Gonzalez & R. Woods www.Digital Image Processing.com . E.

Chapter 5 Image Restoration © 2002 R. 2nd ed.imageprocessingbook. Woods www.com . Gonzalez & R.Digital Image Processing. C. E.