0% found this document useful (0 votes)
17 views49 pages

Ch05-Image Restoration

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1/ 49

Digital Image Processing, 2nd ed.

1
www.imageprocessingbook.com

Chapter 5
Image
Restoration

www.ImageProcessingPlace.com
w.csie.ntnu.edu.tw/~violet/IP93/Chapter05.ppt
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. 2
www.imageprocessingbook.com

A Model of the Image Degradation/Restoration


Reading: [Xeon, Exercise 5 – Q. 1]
Image Enhancement
• Typically based on subjective criteria
• Filters are applied interactively until image quality has been
improved in the eyes of the end user
• Example: Contrast stretching
Image Restoration
• Based on objective criteria
• An image degradation process is modeled (mathematically or
otherwise) by using priori knowledge. The inverse of the
degradation process is applied to enhance the image. Objective
(mathematical or statistical) measurements are used to determine
the degree of success
• Example: Removal of image blur
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. 3
www.imageprocessingbook.com

A Model of the Image Degradation/Restoration

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


Spatial Domain: g(x, y) = h(x, y)*f(x, y) + (x, y)
Frequency Domain: G(u, v) = H(u, v)*F(u, v) + N(u, v)
H(u, v) is an Optical Transfer Function (OTF)
h(x, y) is a Point Spread Function (PSF)
OTF & PSF are Fourier transform pair
Degradation process => Convolution Restoration process => Deconvolution
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. 4
www.imageprocessingbook.com

Noise Models

• The principal source of noise in digital images


arise during image acquisition (digitization)
and/or transmission.
• The performance of imaging sensors is
affected by a variety of factors.
• Images are corrupted during transmission due
to interference in channel

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


Digital Image Processing, 2nd ed. 5
www.imageprocessingbook.com

Noise Models
Spatial & Frequency Properties of Noise

• With the exception of spatially periodic noise,


noise is independent of spatial coordinates,
and it is uncorrelated with respect to the image
itself.
• We can describe that spatial noise is concerned
with the statistical behavior of the gray-level
values.
• Noise in spatial domain is described by PDF or
CDF
• Noise in frequency domain is described by
Fourier properties of the noise
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. 6
www.imageprocessingbook.com

Noise Models
Adding Noise with Function imnoise

Syntax: g = imnoise(f, type, parameters)


>> f = imread('cktboard.tif');
>> g = imnoise(f, 'salt & pepper', 0.2);
>> h = imnoise(f, 'gaussian', 0, 0.01);
>> imshow(f), figure, imshow(g), imshow(h)

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


Digital Image Processing, 2nd ed. 7
www.imageprocessingbook.com

Noise Models
Some Important Noises

1. Gaussian noise
2. Rayleigh noise
3. Erlang (Gamma) noise
4. Exponential noise
5. Uniform noise
6. Impulse (salt-and-
pepper) noise

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


Digital Image Processing, 2nd ed. 8
www.imageprocessingbook.com

Noise Models
Noise PDFs

1. Gaussian Noise:
  z   2
1
p( z )  e 2 2
p(z)
2
where z represents gray level,  is
the mean of average value of z,
 is its standard deviation.
This noise arises in an image due to
factors such as electronic circuit
noise and sensor noise due to
poor illumination or/and high
temperature.     z

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

Noise Models
Noise PDFs

2. Rayleigh Noise:
2 ( z a )2
 z  a e b
for z  a p(z)
p( z )   b
0 for z  a

b( 4   )
  a  b / 4 ,  2 
4

It is helpful in characterizing noise


phenomena in range imaging.

a z
a b
2

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


Digital Image Processing, 2nd ed. 10
www.imageprocessingbook.com

Noise Models
Noise PDFs

3. Erlang (Gamma) Noise:


p(z)
a z  az
b b 1
K
a (b  1) b 1 ( b 1)
e
 e for z  a K (b  1)!
p ( z )   (b  1)!
0 for z  a

b b
 ,   2
2

a a
Find applications in laser imaging.

b 1 z
a
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. 11
www.imageprocessingbook.com

Noise Models
Noise PDFs

4. Exponential Noise:
p(z)
ae  az
for z  a
p( z )   a
0 for z  a
1 1
 ,   2
2

a a

Find applications in laser imaging.

z
It is a special case of Erlang PDF, with b=1.
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. 12
www.imageprocessingbook.com

Noise Models
Noise PDFs

5. Uniform Noise:
 1 p(z)
 if a  z  b
p( z )   b  1
0 otherwise 1
ba
ab (b  a ) 2
 , 2 
2 12
Least descriptive of practical
applications, however quite
useful as the basis for numerous
random number generators that
are used in simulations. a b z

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


Digital Image Processing, 2nd ed. 13
www.imageprocessingbook.com

Noise Models
Noise PDFs

6. Impulse (salt-and-pepper) Noise:


p(z)
 Pa for z  a

p ( z )   Pb for z  b
Pb
0 otherwise

Pa

It is found in situations where quick


transients, such as faulty
switching take place during
imaging z
a b
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. 14
www.imageprocessingbook.com

Noise Models
Noise PDFs

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


Digital Image Processing, 2nd ed. 15
www.imageprocessingbook.com

Noise Models
Noise PDFs

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


Digital Image Processing, 2nd ed. 16
www.imageprocessingbook.com

Noise Models
Noise PDFs

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


Digital Image Processing, 2nd ed. 17
www.imageprocessingbook.com

Noise Models
Noise PDFs

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


Digital Image Processing, 2nd ed. 18
www.imageprocessingbook.com

Noise Models
Noise PDFs

>> M = 100000; 8000

>> N = 1; 7000
>> a = 0;
6000
>> b = 1;
>> r = a + b*randn(M, N); 5000

>> hist(r, 50); 4000

3000

2000

1000

0
-5 -4 -3 -2 -1 0 1 2 3 4 5

Histogram of Gaussian random numbers

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


Digital Image Processing, 2nd ed. 19
www.imageprocessingbook.com

Noise Models
Noise PDFs

Exercise: [1, p. 162]


Write an M function:
R = imnoise2(type, M, N, a, b)
and display histograms

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


Digital Image Processing, 2nd ed. 20
www.imageprocessingbook.com

Restoration in the Presence of Noise Only

• When the only degradation present in an image is


noise:
g ( x, y )  f ( x, y )   ( x, y )

• The noise is unknown, so subtracting them from


g(x, y) is not a realistic option.
• In fact, enhancement and restoration become
almost indistinguishable disciplines in this
particular case.

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


Digital Image Processing, 2nd ed. 21
www.imageprocessingbook.com

Spatial Noise Filters

Reducing noise in spatial domain is simple:

• Mean Filters
• Order Statistics Filters
• Adaptive Filters

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


Digital Image Processing, 2nd ed. 22
www.imageprocessingbook.com

Spatial Noise Filters


Mean Filters
• Arithmetic mean filter
• Geometric mean filter
• Harmonic mean filter
• Contraharmonic mean filter

Let Sxy represent the set of coordinates in a


rectangular sub-image window of size mn,
centered at point (x, y).
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. 23
www.imageprocessingbook.com

Spatial Noise Filters


Mean Filters
Arithmetic Mean Filter
• Compute the average value of the corrupted image g(x,y) in the area
defined by Sxy
• The value of the restored image atˆ any point (x,y) is
f
ˆf ( x, y )  1
 g ( s, t )
mn ( s ,t )S x , y
• Operation can be implemented using a convolution mask in which all
coefficients have value 1/mn.
• Noise is reduced as a result of blurring.
• Works very well for symmetric random (Gaussian or uniform) noise
distributions

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


Digital Image Processing, 2nd ed. 24
www.imageprocessingbook.com

Spatial Noise Filters


Mean Filters
Geometric Mean Filter
• Given by the expression: 1

  mn

fˆ ( x, y )    g ( s, t )
( s ,t )S xy 
• Achieves smoothness comparable to the arithmetic mean filter
• Tends to lose less image detail in the process.
• Works very well for random symmetric (Gaussian or uniform) noise
distributions
• Does not work for negative impulse noise (pepper noise)

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


Digital Image Processing, 2nd ed. 25
www.imageprocessingbook.com

Spatial Noise Filters


Mean Filters

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


Digital Image Processing, 2nd ed. 26
www.imageprocessingbook.com

Spatial Noise Filters


Mean Filters
Harmonic Mean Filter
• Given by the expression:
mn
fˆ ( x, y ) 
1

( s ,t )S xy g ( s, t )

• Works well for salt noise (positive impulse noise)


• Fails for pepper noise (negative impulse noise)
• Also works well for other types of noise (such as Gaussian
noise)

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


Digital Image Processing, 2nd ed. 27
www.imageprocessingbook.com

Spatial Noise Filters


Mean Filters
Contraharmonic Mean Filter
• Given by the expression:
 g ( s ,
( s ,t )S xy
t ) Q 1

fˆ ( x, y ) 
 g ( s , t ) Q

• Q is referred to as the order of the filter ( s ,t )S xy


• Works very well for unipolar impulse noise
• Positive values for Q reduces pepper noise (negative impulse noise)
• Negative values for Q reduces salt noise (positive impulse noise)
• Reduces to arithmetic mean filter for Q = 0
• Reduces to the harmonic mean filter for Q = -1

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


Digital Image Processing, 2nd ed. 28
www.imageprocessingbook.com

Spatial Noise Filters


Mean Filters

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


Digital Image Processing, 2nd ed. 29
www.imageprocessingbook.com

Spatial Noise Filters


Mean Filters

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


Digital Image Processing, 2nd ed. 30
www.imageprocessingbook.com

Spatial Noise Filters


Order-Statistics Filters
Order-Statictics filters are spatial filters whose
response is based on ordering (ranking) the pixels
contained in the image area encompassed by the
filter
– Median filter
– Max and Min filter
– Midpoint filter
– Alpha-trimmed mean filter
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. 31
www.imageprocessingbook.com

Spatial Noise Filters


Order-Statistics Filters
Median Filter
• Given by the expression:

fˆ ( x, y )  mediang ( s, t )
( s ,t )S xy

• Can be used iteratively


• Works very well for all types of impulse noise
• It represents the 50th percentile of a ranked set of numbers

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


Digital Image Processing, 2nd ed. 32
www.imageprocessingbook.com

Spatial Noise Filters


Order-Statistics Filters

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


Digital Image Processing, 2nd ed. 33
www.imageprocessingbook.com

Spatial Noise Filters


Order-Statistics Filters
Max and Min Filter
• Using the 100th percentile results in the so-called max filter,
given by ˆ f ( x, y )  max g ( s, t )
( s ,t )S xy
This filter is useful for finding the brightest points in an image.
Since pepper noise has very low values, it is reduced by this filter
as a result of the max selection processing the subimage area Sxy.
• The 0th percentile filter is min filter:
ˆ ( x, y )  min g ( s, t )
f
This filter is useful for finding the darkest points in an image.
( s ,t )S xy
Also, it reduces salt noise as a result of the min operation.

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


Digital Image Processing, 2nd ed. 34
www.imageprocessingbook.com

Spatial Noise Filters


Order-Statistics Filters

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


Digital Image Processing, 2nd ed. 35
www.imageprocessingbook.com

Spatial Noise Filters


Order-Statistics Filters
Midpoint Filter
The midpoint filter simply computes the midpoint between the
maximum and minimum values in the area encompassed by the
filter:
1
f ( x, y )   max g ( s, t ) min g ( s, t )
2 ( s ,t )S xy ( s ,t )S xy 

Works best for symmetric random (Gaussian or uniform) noise

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


Digital Image Processing, 2nd ed. 36
www.imageprocessingbook.com

Spatial Noise Filters


Order-Statistics Filters
Alpha-trimmed Mean Filter
• Suppose that we delete the d/2 lowest and the d/2 highest gray-level
values of g(s,t) in the area Sxy.
• Let gr(s,t) represent the remaining mn-d pixels. And averaging these
remain pixels is denoted as:
1
fˆ ( x, y ) 
mn  d
 g ( s, t )
( s ,t )S xy
r

• Where the value of d can range from 0 to mn-1. When d=0, It is


arithmetic mean filter and d=(mn-1)/2 is a median filter.
• It is useful for the multiple types of noise such as the combination of
salt-and-pepper and Gaussian noise.

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


Digital Image Processing, 2nd ed. 37
www.imageprocessingbook.com

Spatial Noise Filters


Order-Statistics Filters

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


Digital Image Processing, 2nd ed. 38
www.imageprocessingbook.com

Spatial Noise Filters

Exercise:
1. Knowing that an image is contaminated by Gaussian and/or salt-
and-pepper noise, recover it by using restoration filters
2. Write an M-function [1, 5.3.1]:
f = spfilt(g, type, m, n, parameter)
which can perform filtering in the
spatial domain with any of the filters
listed in Table 5.2
3. [2, 5.10-5.11]

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


Digital Image Processing, 2nd ed. 39
www.imageprocessingbook.com

Spatial Noise Filters


Exercise: [2, 5.1-5.9]
White bars in the test pattern shown are 7 pixels wide and 210 pixels high. The
separation between bars is 17 pixels. What would this image look like after
separation of
a. 33
b. 77
c. 99
1. arithmetic mean filter
2. geometric mean filter
3. harmonic mean filter
4. contraharmonic mean filter with Q=-1
5. contraharmonic mean filter with Q=1
6. median filter
7. max filter
8. min filter
9. midpoint filter
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. 40
www.imageprocessingbook.com

Spatial Noise Filters

Assignment:
With given image “bars.tif” apply the M-function spfilt.m
and solve questions:
[2, 5.1-5.9]

Deliverables: Hardcopy of
M-function code & all the results

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


Digital Image Processing, 2nd ed. 41
www.imageprocessingbook.com

Spatial Noise Filters


Adaptive Filters
• Adaptive filters change their behavior based on the statistical
properties of the pixel within the filter neighborhood
• Adaptive filters are generally capable of higher performance
than regular filters
• The price paid for this enhanced performance is an increase in
computational complexity
• Statistical properties are intuitive to use
– mL (mean): a measure of the average gray level within filter
neighborhood
– σ2L (variance): a measure of the average contrast within filter
neighborhood

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


Digital Image Processing, 2nd ed. 42
www.imageprocessingbook.com

Spatial Noise Filters


Adaptive Filters

• Adaptive Mean Filter


• Adaptive Median Filter

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


Digital Image Processing, 2nd ed. 43
www.imageprocessingbook.com

Spatial Noise Filters


Adaptive Filters

Adaptive Mean Filter


ˆf ( x, y )  g ( x, y )    g ( x, y )  m 
2

L 2 L

• σ2η – the variance of the noise in the (entire) image (assumed to be  σ2L)
• σ2L – the local variance (within filter neighborhood)
• mL – the local mean

• σ2η zero  no noise  return the original


• σ2η approaching σ2L  heavy noise  average filtering
• σ2L high  edge content  return the original (preserve edges)

• Requires knowledge of σ2η


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

Spatial Noise Filters


Adaptive Filters

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


Digital Image Processing, 2nd ed. 45
www.imageprocessingbook.com

Spatial Noise Filters


Adaptive Filters
Adaptive Median Filter
• zmin – minimal intensity value in Sxy
• zmax – maximum intensity value in Sxy
• zmed – median of the intensity value in Sxy
• zxy – intensity value at coordinates (x, y)

• Smax – maximum allowed size of the adaptive filter window

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


Digital Image Processing, 2nd ed. 46
www.imageprocessingbook.com

Spatial Noise Filters


Adaptive Filters
Adaptive Median Filter
Level A: If zmin < zmed < zmax
go to level B
else
increase window size
if window size <= Smax
go to level A
else
return zmed =>
or return zxy instead of zmed,
producing slightly less blurred
Level B: if zmin < zxy < zmax
result but can fail to detect salt
return zxy (pepper) noise embedded in a
else constant background having the
return zmed same value as pepper (salt) noise
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. 47
www.imageprocessingbook.com

Spatial Noise Filters


Adaptive Filters
Adaptive Median Filter
• The adaptive median filter grows the neighborhood if there aren’t enough spread
on the pixel values within the neighborhood
• If the neighborhood has reached its maximal size no filtering is applied since
there aren’t enough varied pixel values to classify the pixel available
• A median filtering is performed (only) if the current pixel constitute either a local
minima or a local maxima

Compared to the regular median filter, the adaptive median filter


• is capable of handling more frequently occurring impulse noise
• seeks to preserve image detail when smoothing non-impulse noise (introduces
less distortion due to the preservation of “non-impulse” pixels)
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. 48
www.imageprocessingbook.com

Spatial Noise Filters


Adaptive Filters
Adaptive Median Filter
Exercise: [1, Appendix C] Write an M-Function: f = adpmedian(g, Smax)

>> g = imnoise(f, ‘Salt & pepper’, .25);


>> f1 = medianfilt2(g, [7, 7], ‘symmetric’);
>> f2 = adpmedian(g, 7);

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


Digital Image Processing, 2nd ed. 49
www.imageprocessingbook.com

References
1. Gonzalez R. C., Woods R. E., Eddins S. L., Digital Image
Processing Using Matlab, Pearson Education, 2006.
2. Gonzalez R. C., Woods R. E., Digital Image Processing,
Pearson Education, 2006.
3. http://www.imageprocessingplace.com/

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

You might also like