Image Restoration
Image Restoration
( , ) ( , )
x y
s t S
f x y g s t
mn
e
=
f
1.b Geometric Mean Filter
3/24/2012 CS 04 804B Image Processing Module 2 28
Achieves smoothing comparable to arithmetic mean
filter but tends to lose image detail in the process.
1.c Harmonic Mean Filter
Works well for salt noise but fails for pepper
noise.
Works well with other types of noise like
Gaussian noise.
3/24/2012 CS 04 804B Image Processing Module 2 29
1.d Contraharmonic Mean Filter
| |
| |
1
( , )
( , )
( , )
( , )
( , )
xy
xy
Q
s t S
Q
s t S
g s t
f x y
g s t
+
e
e
=
( , ) ( , )
xy
s t S
f x y median g s t
e
=
3/24/2012 CS 04 804B Image Processing Module 2 33
Replaces the value of a pixel by the median of
graylevels in the neighborhood of that pixel.
Median represents the 50
th
percentile of a ranked set of
numbers.
For random noise, it provides excellent noise-reduction
with lesser blurring than linear smoothing filters of
similar size.
Effective for Bipolar and Unipolar impulse noise.
2.b Max and Min Filters
Max filter
Uses 100
th
percentile.
Used for finding the brightest points in an image.
Reduces pepper noise.
Min filter
Uses 0
th
percentile.
Used for finding the darkest points in the image.
Reduces salt noise.
3/24/2012 CS 04 804B Image Processing Module 2 34
{ }
( , )
( , ) max ( , )
xy
s t S
f x y g s t
e
=
{ }
( , )
( , ) min ( , )
xy
s t S
f x y g s t
e
=
2.c Midpoint Filter
Computes midpoint between the maximum and
minimum values in the area encompassed by the filter.
Works best for randomly distributed noise (Gaussian
or uniform noise).
3/24/2012 CS 04 804B Image Processing Module 2 35
{ } { }
( , ) ( , )
1
( , ) max ( , ) min ( , )
2
xy xy
s t S s t S
f x y g s t g s t
e e
(
= +
(
2.d Alpha-trimmed Filters
If d/2 lowest and d/2 highest gray-level values of
g(s,t) in the neighborhood S
xy
are deleted, and if
g
r
(s,t) represents the remaining mn-d pixels, then the
alpha-trimmed mean filter formed by averaging the
remaining pixels is given by
3/24/2012 CS 04 804B Image Processing Module 2 36
Where, d ranges from 0 to mn-1.
When d=0, the filter reduces to arithmetic mean filter.
When d= (mn-1)/2, the filter reduces to median filter.
( , )
1
( , ) ( , )
xy
r
s t S
f x y g s t
mn d
e
=
Order-Statistics Filters
Median Filter
Max and Min Filters
Mid-point Filter
Alpha-trimmed Mean Filter
Adaptive Filters
Adaptive, local noise reduction filter
Adaptive median filter
Frequency Domain Filtering - Periodic Noise Reduction
Bandreject Filters
Bandpass Filters
Notch Filters
Linear Position-Invariant Degradations
Inverse Filtering
Minimum Mean Square Error (MMSE) or Weiner Filtering
Constrained Least Squares Filtering
Geometric Mean Filter
3/24/2012 37 CS 04 804B Image Processing Module 2
3/24/2012 CS 04 804B Image Processing Module 2 38
Adaptive, Local Noise Reduction Filter
Mean measure of average gray-level in a region.
Variance measure of average contrast in a region.
Response of a filter at (x,y) operating on a region S is based on:
g(x,y) the value of noisy image at (x,y)
2
( , ) ( , ) ( , )
L
L
f x y g x y g x y m
q
o
o
=
Adaptive Median Filter
Can handle impulse noise with larger probabilities.
Preserves detail while smoothing non-impulse noise.
Adaptive median filter increases the size of subimage
during filter operations.
Output of any filter is a single value used to replace the
value of the pixel at (x,y), the point on which the window
is centered at a given time.
3/24/2012 CS 04 804B Image Processing Module 2 40
z
min
= minimum gray level value in S
xy
.
z
max
= maximum gray level value in S
xy
.
z
med
= median of gray levels in S
xy
.
z
xy
= gray level at coordinates (x,y).
S
max
= maximum allowed size of S
xy
.
3/24/2012 CS 04 804B Image Processing Module 2 41
Two-level algorithm
Level A:
A1 = z
med
- z
min
A2 = z
med
- z
max
If A1>0 AND A2<0, goto level B.
Else increase the window size.
If window size S
max
, repeat level A.
Else output z
xy
.
Level B:
B1 = z
xy
- z
min
B2 = z
xy
- z
max
If B1>0 AND B2<0, output z
xy
.
Else output z
med
.
3/24/2012 CS 04 804B Image Processing Module 2 42
Three main purposes:
To remove salt-and-pepper noise
To provide smoothing of other noise that may not be
impulsive
To reduce distortion(excessive thinning or thickening of
object boundaries).
3/24/2012 CS 04 804B Image Processing Module 2 43
Z
min
and z
max
are considered impulse-like noise
components.
Purpose of level A is to determine if the median filter
output z
med
is an impulse (black or white) noise or not.
If the condition z
min
< z
med
< z
max
holds, then z
med
cannot
be an impulse. Goto level B and test to see if the point z
xy
in the centre of the window is itself an impulse.
If B1>0 AND B2<0, then z
min
< z
xy
< z
max.
z
xy
cannot be an
impulse. Algorithm outputs z
xy
.
3/24/2012 CS 04 804B Image Processing Module 2 44
If the condition B1>0 AND B2<0 does not hold, then
either z
xy
= z
min
or z
xy
= z
max
. In either case, the value of
pixel is an extreme value and the algorithm outputs the
median value, z
med
.
Suppose, A finds an impulse. Then, it increases the size of
the window and repeats level A. Continues until the
algorithm either finds a median value that is not an
impulse or maximum window size is reached.
3/24/2012 CS 04 804B Image Processing Module 2 45
Order-Statistics Filters
Median Filter
Max and Min Filters
Mid-point Filter
Alpha-trimmed Mean Filter
Adaptive Filters
Adaptive, local noise reduction filter
Adaptive median filter
Frequency Domain Filtering - Periodic Noise Reduction
Bandreject Filters
Bandpass Filters
Notch Filters
Linear Position-Invariant Degradations
Inverse Filtering
Minimum Mean Square Error (MMSE) or Weiner Filtering
Constrained Least Squares Filtering
Geometric Mean Filter
3/24/2012 46 CS 04 804B Image Processing Module 2
3/24/2012 CS 04 804B Image Processing Module 2 47
Bandreject Filters
Bandreject filters remove (or attenuate) a band of
frequencies, around some frequency, say D
0
.
An ideal bandreject filter is given by:
where
( )
2 2
, v u v u D + =
0
0 0
0
1 ( , )
2
( , ) 0 ( , )
2 2
1 ( , )
2
W
if D u v D
W W
H u v if D D u v D
W
if D u v D
<
= s s +
> +
2
2 2
0
( , ) 1
2 ( , )
( , ) 1
D u v D
D u v W
H u v e
(
(
(
=
CS 04 804B Image Processing Module 2
3/24/2012 50
Bandreject Filters
CS 04 804B Image Processing Module 2
3/24/2012 51
Example: Bandreject Filters
CS 04 804B Image Processing Module 2
3/24/2012 52
Bandpass Filters
Bandpass filters perform the opposite operation of bandreject
filters. They pass a band of frequencies, around some
frequency, say D
0
(rejecting the rest).
The transfer function of a bandpass filter is obtained from a
corresponding bandreject filter as:
H
bp
(u,v) = 1 - H
br
(u,v)
CS 04 804B Image Processing Module 2
Bandpass filter is usually used to isolate components
of an image that correspond to a band of frequencies.
It can also be used to isolate noise pattern, so that a
more detailed analysis of the noise can be
performed, independent of the image.
3/24/2012 CS 04 804B Image Processing Module 2 53
3/24/2012 54 CS 04 804B Image Processing Module 2
3/24/2012 55
Notch Filters
It is a kind of bandreject/bandpass filter that
rejects/passes a very narrow set of frequencies, around a
center frequency.
Due to symmetry of Fourier transform, the notch filters
must occur in symmetric pairs about the origin of the
frequency plane.
CS 04 804B Image Processing Module 2
The transfer function of an ideal notch-reject filter of
radius D
0
with centers at (u
0
,v
0
) and (-u
0
,-v
0
) is given by:
Where
And
3/24/2012 CS 04 804B Image Processing Module 2 56
1 0 2 0
0 ( , ) ( , )
( , )
1
if D u v D or D u v D
H u v
otherwise
s s
1
2 2
2
1 0 0
( , )
2 2
M N
D u v u u v v
(
| | | |
= +
(
| |
\ . \ .
(
1
2 2
2
2 0 0
( , )
2 2
M N
D u v u u v v
(
| | | |
= + + +
(
| |
\ . \ .
(
The transfer function of a Butterworth notch-reject filter
of order n is given by:
A Gaussian notch reject filter has the form
3/24/2012 CS 04 804B Image Processing Module 2 57
2
0
1 2
1
( , )
1
( , ) ( , )
n
H u v
D
D u v D u v
=
(
+
(
1 2
2
0
( , ) ( , ) 1
2
( , ) 1
D u v D u v
D
H u v e
(
(
(
=
3/24/2012 58 CS 04 804B Image Processing Module 2
Notch-pass filter passes the frequencies contained in the
notch areas.
Performs exactly the opposite function as notch-reject
filters.
Transfer function is given by:
H
np
(u,v) = 1 - H
nr
(u,v)
3/24/2012 CS 04 804B Image Processing Module 2 59
3/24/2012 60
Optimum Notch Filtering
When several interference patterns are present,
filtering may remove much image information.
Solution - first filter out the noise interference by
placing a notch pass filter H(u,v) at the location of
each spike:
N(u,v) = H(u,v)G(u,v)
G(u,v) is the Fourier transform of the corrupted
image.
CS 04 804B Image Processing Module 2
Corresponding pattern in the spatial domain is obtained as
q(x,y) = F
-1
{N(u,v)} = F
-1
{H(u,v) G(u,v)}
We can then subtract off a weighted portion of q(x,y)
from the image g(x,y) to obtain our restored image:
w(x,y) is called weighting or modulation function. It can
be chosen so as to minimize the variance of the estimate
over a specified neighbourhood of every point
(x,y).
(Refer word doc for derivation)
3/24/2012 CS 04 804B Image Processing Module 2 61
( , ) ( , ) ( , ) ( , ) f x y g x y w x y x y q
.
=
( , ) f x y
.
Order-Statistics Filters
Median Filter
Max and Min Filters
Mid-point Filter
Alpha-trimmed Mean Filter
Adaptive Filters
Adaptive, local noise reduction filter
Adaptive median filter
Frequency Domain Filtering - Periodic Noise Reduction
Bandreject Filters
Bandpass Filters
Notch Filters
Linear Position-Invariant Degradations
Inverse Filtering
Minimum Mean Square Error (MMSE) or Weiner Filtering
Constrained Least Squares Filtering
Geometric Mean Filter
3/24/2012 62 CS 04 804B Image Processing Module 2
3/24/2012 63
Linear, Position-Invariant Degradations
Input-output relationship before restoration stage
g(x,y) = H[f(x,y)] + (x,y)
Assume (x,y) = 0.
Therefore, g(x,y) = H[f(x,y)]
H is linear if :
H[af
1
(x,y)+bf
2
(x,y)] = aH[f
1
(x,y)]+bH[f
2
(x,y)]
CS 04 804B Image Processing Module 2
If a = b = 1, H[f
1
(x,y)+f
2
(x,y)] = H[f
1
(x,y)]+H[f
2
(x,y)]
This property is called additivity.
If f
2
(x,y) = 0, H[af
1
(x,y)] = aH[f
1
(x,y)]
This property is called homogeneity.
An operator satisfying g(x,y) = H[f(x,y)] is said to be position
invariant if:
H[ f (x-, y-) ] = g( x-, y- )
That is, response at any point in the image depends only
on the value of input at that point, not in its position.
3/24/2012 CS 04 804B Image Processing Module 2 64
In terms of continuous impulse function,
3/24/2012 CS 04 804B Image Processing Module 2 65
( , ) ( , ) ( , ) f x y f x y d d o | o o | o |
=
} }
| |
| |
( , , , )
( , ) [ ( , )]
( , ) ( , )
( , ) ( , )
( , ) ( , )
h x y
g x y H f x y
H f x y d d
H f x y d d
f H x y d d
o |
o | o o | o |
o | o o | o |
o | o o | o |
=
(
=
(
=
=
} }
} }
} }
h (x,, y,) is the impulse response of H.
If (x,y) = 0,
This is called the superposition integral of the first kind.
A linear system h is completely characterized by its
impulse response.
If H is position invariant,
3/24/2012 CS 04 804B Image Processing Module 2 66
( , ) ( , ) ( , , , ) g x y f h x y d d o | o | o |
=
} }
| |
( , ) ( , ) H x y h x y o o | o | =
( , ) ( , ) ( , ) g x y f h x y d d o | o | o |
=
} }
is called the convolution integral.
That is, the response g is the convolution of impulse
response and the input function.
3/24/2012 CS 04 804B Image Processing Module 2 67
( , ) ( , ) f h x y d d o | o | o |
} }
Convolution
3/24/2012 CS 04 804B Image Processing Module 2 68
3/24/2012 CS 04 804B Image Processing Module 2 69
Presence of Noise
If H is position invariant,
3/24/2012 CS 04 804B Image Processing Module 2 70
( , ) ( , ) ( , , , ) ( , ) g x y f h x y d d x y o | o | o | q
= +
} }
( , ) ( , ) ( , ) ( , )
( , ) * ( , ) ( , )
g x y f h x y d d x y
h x y f x y x y
o | o | o | q
q
= +
= +
} }
( , ) ( , ) ( , ) ( , ) G u v H u v F u v N u v = +
Degradation is modeled as convolution.
Restoration is modeled as deconvolution.
Restoration filters are hence called deconvolution filters.
3/24/2012 CS 04 804B Image Processing Module 2 71
Estimating the degradation
function
Estimation by observation
Estimation by experimentation
Estimation by mathematical modeling
3/24/2012 CS 04 804B Image Processing Module 2 72
Estimation by Observation
No knowledge about the degradation function H.
Gather information from image itself.
Let: g
s
(x,y) be the observed subimage.
be the constructed subimage.
Assume negligible noise (choose strong signal area).
Then,
From the characteristics of H
s
, deduce the complete
function H(u,v) assuming position invariance.
3/24/2012 CS 04 804B Image Processing Module 2 73
( , ) f x y
.
( , )
( , )
( , )
s
s
s
G u v
H u v
F u v
.
=
Estimation by Experimentation
Accurate estimate of the degradation can be obtained if
device similar to the one used for capturing degraded
image is available.
Obtain the impulse response of degradation by imaging an
impulse using the same system settings.
Linear space invariant system is completely described by
its impulse response.
3/24/2012 CS 04 804B Image Processing Module 2 74
3/24/2012 CS 04 804B Image Processing Module 2 75
Assume negligible noise.
Fourier transform of an impulse is a constant which
describes the strength of the impulse.
3/24/2012 CS 04 804B Image Processing Module 2 76
( , )
( , )
G u v
H u v
A
=
Estimation by Modeling
A) Takes into account the environmental conditions
Where k is a constant that depends on nature of
atmospheric turbulence.
3/24/2012 CS 04 804B Image Processing Module 2 77
( )
5
2 2
6
( , )
k u v
H u v e
+
=
B) Image blurred due to uniform and linear motion
between image and sensor during acquisition.
Let f(x,y) undergo planar motion.
x
0
(t) and y
0
(t) be the time varying components of motion
in x and y directions.
Total exposure at any point of recording medium is
obtained by integrating instantaneous exposure over the
time interval during which the shutter is open.
Let T be the duration of exposure.
3/24/2012 CS 04 804B Image Processing Module 2 78
3/24/2012 CS 04 804B Image Processing Module 2 79
0 0
0
( , ) ( ( ), ( ))
T
g x y f x x t y y t dt =
}
2 ( )
( , ) ( , )
j ux vy
G u v g x y e dxdy
t
+
=
} }
2 ( )
0 0
0
( ( ), ( ))
T
j ux vy
f x x t y y t dt e dxdy
t
+
(
=
(
} } }
3/24/2012 CS 04 804B Image Processing Module 2 80
0 0
0 0
2 ( )
0 0
0
( , )
2 ( ( ) ( ))
0
2 ( ( ) ( ))
0
( ( ), ( ))
( , )
( , )
T
j ux vy
shifted F u v
T
j ux t vy t
T
j ux t vy t
f x x t y y t e dxdy dt
F u v e dt
F u v e dt
t
t
t
+
+
+
(
(
= (
(
(
(
=
(
=
} } }
}
}
3/24/2012 CS 04 804B Image Processing Module 2 81
0 0
2 ( ( ) ( ))
0
,
( , )
( , ) ( , ) ( , )
T
j ux t vy t
Define the transfer function
H u v e dt
G u v H u v F u v
t +
(
=
=
}
Order-Statistics Filters
Median Filter
Max and Min Filters
Mid-point Filter
Alpha-trimmed Mean Filter
Adaptive Filters
Adaptive, local noise reduction filter
Adaptive median filter
Frequency Domain Filtering - Periodic Noise Reduction
Bandreject Filters
Bandpass Filters
Notch Filters
Linear Position-Invariant Degradations
Inverse Filtering
Minimum Mean Square Error (MMSE) or Weiner Filtering
Constrained Least Squares Filtering
Geometric Mean Filter
3/24/2012 82 CS 04 804B Image Processing Module 2
Inverse Filtering
The simplest method to restore images degraded by a
degradation function H is direct inverse filtering.
It computes an estimate of the transform of the
original image as
3/24/2012 CS 04 804B Image Processing Module 2 83
( , ) F u v
.
( , )
( , )
( , )
G u v
F u v
H u v
.
=
Cannot restore the image exactly with knowledge of
H(u,v) because N(u,v) is unknown.
If H(u,v) has values 0, will dominate F(u,v).
3/24/2012 CS 04 804B Image Processing Module 2 84
( , ) ( , ) ( , ) ( , )
( , ) ( , ) ( , ) ( , ) ( , )
( , )
( , ) ( , )
( , )
G u v H u v F u v N u v
F u v H u v H u v F u v N u v
N u v
F u v F u v
H u v
.
.
= +
= +
= +
( , )
( , )
N u v
H u v
Inverse filtering is hence very sensitive to noise and has
no provision to handle noise.
One way to avoid values of H(u,v) that tend to zero is to
limit the filter frequencies to values near the origin.
H(0,0), the average value of h(x,y) is the highest value of
H(u,v).
Blurring (degradation) corresponds to lowpass filtering
and inverse filtering corresponds to highpass filtering.
3/24/2012 CS 04 804B Image Processing Module 2 85
Order-Statistics Filters
Median Filter
Max and Min Filters
Mid-point Filter
Alpha-trimmed Mean Filter
Adaptive Filters
Adaptive, local noise reduction filter
Adaptive median filter
Frequency Domain Filtering - Periodic Noise Reduction
Bandreject Filters
Bandpass Filters
Notch Filters
Linear Position-Invariant Degradations
Inverse Filtering
Minimum Mean Square Error (MMSE) or Weiner Filtering
Constrained Least Squares Filtering
Geometric Mean Filter
3/24/2012 86 CS 04 804B Image Processing Module 2
Wiener (MMSE) Filtering
Refer Page: 284-286
3/24/2012 CS 04 804B Image Processing Module 2 87
Refer Page: 288-291
Laplacian Operator
3/24/2012 CS 04 804B Image Processing Module 2 88
Constrained Least Squares Filtering
2 2
2
2 2
2
2
2
2
2
( 1, ) ( 1, ) 2 ( , )
( , 1) ( , 1) 2 ( , )
( 1, ) ( 1, )
( , 1) ( , 1) 4 ( , )
f f
f
x y
f
f x y f x y f x y
x
f
f x y f x y f x y
y
f f x y f x y
f x y f x y f x y
c c
V = +
c c
c
= + +
c
c
= + +
c
V = + + +
+ +
3/24/2012 CS 04 804B Image Processing Module 2 89
( ) ( ) ( )
( ) ( ) ( )
( ) ( ) ( )
( 1, 1) ( , 1) ( 1, 1)
( , ) ( 1, ) ( , ) ( 1, )
( 1, 1) ( , 1) ( 1, 1)
0 1 0
1 4 1
0 1 0
coeff f x y coeff f x y coeff f x y
p x y coeff f x y coeff f x y coeff f x y
coeff f x y coeff f x y coeff f x y
+ + + + (
(
= +
(
(
+
(
(
=
(
(
Geometric Mean Filter
Refer Page: 292
3/24/2012 CS 04 804B Image Processing Module 2 90
Thank You
3/24/2012 CS 04 804B Image Processing Module 2 91