Contents
In this lecture we will look at image restoration
techniques used for noise removal
– What is image restoration?
– Noise and images
– Noise models
– Noise removal using spatial domain filtering
– Periodic noise
– Noise removal using frequency domain filtering
– Inverse filtering
2
What is Image Restoration?
Image restoration attempts to restore images that
have been degraded
– Identify the degradation process and attempt to
reverse it
– Similar to image enhancement, but more
objective
3
Noise and Images
The sources of noise in digital
images arise during image
acquisition (digitization) and
transmission
– Imaging sensors can be
affected by ambient conditions
– Interference can be added
to an image during transmission
4
Noise Model
We can consider a noisy image to be modelled as
follows:
g ( x, y) f ( x, y) ( x, y)
where f(x, y) is the original image pixel,
η(x, y) is the noise term and
g(x, y) is the resulting noisy pixel.
If we can estimate the model of the noise in an
image, this will help us to figure out how to restore
the image.
5
Noise Models
There are many different
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Gaussian Rayleigh
models for the image
noise term η(x, y):
– Gaussian (most common)
– Rayleigh Erlang Exponential
– Erlang
– Exponential
– Uniform
– Impulse Uniform
Impulse
• Salt and pepper noise
6
Noise Example
The test pattern to the right is ideal
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
for demonstrating the addition of
noise.
The following slides will show the
result of adding noise based on
Image
various models to this image
Histogram to go here
Histogram 7
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Gaussian
Rayleigh
Erlang
Noise Example (cont…)
8
Noise Example (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Histogram to go here
Exponential Uniform Impulse
9
Filtering to Remove Noise
We can use spatial filters of different kinds to
remove different kinds of noise.
The arithmetic mean filter is a very simple one:
ˆf ( x, y ) 1
1/ 1/ 1/
9 9 9 g ( s, t )
1/ 1/ 1/ mn ( s ,t )S xy
9 9 9
1/ 1/ 1/
where Sxy is the neighborhood and
9 9 9
mxn is the neighborhood size.
This is implemented as the simple smoothing filter.
Blurs the image to remove noise.
10
Noise Removal Example
Original Image x Filtered Image x
54 52 57 55 56 52 51
50 49 51 50 52 53 58
51 204 52 52 0 57 60 68 47
48 50 51 49 53 59 63
49 51 52 55 58 64 67 51 52
148 154 157 160 163 167 170 120 123
151 155 159 162 165 169 172 155 159
Image f (x, y) Image f (x, y)
y y
11
Other Means
There are different kinds of mean filters all of
which exhibit slightly different behaviour:
– Geometric Mean
– Harmonic Mean
– Contraharmonic Mean
12
Other Means (cont…)
Geometric Mean:
1
mn
fˆ ( x, y ) g ( s, t )
( s ,t )S xy
Achieves similar smoothing to the arithmetic mean,
but tends to lose less image detail.
13
Noise Removal Examples
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Image
Original Corrupted
Image by Gaussian
Noise
After a 3x3 After a 3x3
Arithmetic Geometric
Mean Filter Mean Filter
14
Other Means (cont…)
Harmonic Mean:
mn
fˆ ( x, y )
1
( s ,t )S xy g ( s, t )
Works well for salt noise, but fails for pepper noise.
Also does well for other kinds of noise such as
Gaussian noise.
15
Noise Corruption Example
Original Image x Filtered Image x
54 52 57 55 56 52 51
50 49 51 50 52 53 58
51 204 52 52 2 57 60 55 14
48 50 51 49 53 59 63
49 51 52 55 58 64 67
50 54 57 60 63 67 70
51 55 59 62 65 69 72
Image f (x, y) Image f (x, y)
y y
16
Other Means (cont…)
Contraharmonic Mean:
g ( s, t )
( s ,t )S xy
Q 1
fˆ ( x, y )
g ( s, t )
( s ,t )S xy
Q
Q is the order of the filter and adjusting its value
changes the filter’s behaviour.
Positive values of Q eliminate pepper noise.
Negative values of Q eliminate salt noise.
17
Noise Corruption Example
Original Image x Filtered Image x
54 52 57 55 56 52 51
50 49 51 50 52 53 58 Q =0
Q =0
51 204 52 52 2 57 60 67 47
51 53
48 50 51 49 53 59 63
49 51 52 55 58 64 67
Q = -2 Q =1
50 54 57 60 63 67 70
51 55 59 62 65 69 72
Image f (x, y) Image f (x, y)
y y
18
Noise Removal Examples (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Image
Corrupted
by Pepper
Noise
Result of
Filtering Above
with 3x3
Contraharmonic
Q=1.5
19
Noise Removal Examples (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Image
Corrupted
by Salt
Noise
Result of
Filtering Above
with 3x3
Contraharmonic
Q=-1.5
20
Noise Removal Examples (cont…)
Choosing the wrong value for Q when using the
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
contraharmonic filter can have drastic results
21
Order Statistics Filters
Spatial filters that are based on ordering the pixel
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
values that make up the neighbourhood operated
on by the filter
Useful spatial filters include
– Median filter
– Max and min filter
– Midpoint filter
– Alpha trimmed mean filter
22
Median Filter
Median Filter:
fˆ ( x, y) median{g ( s, t )}
( s ,t )S xy
Excellent at noise removal, without the smoothing
effects that can occur with other smoothing filters.
Particularly good when salt and pepper noise is
present.
23
Noise Corruption Example
Original Image x Filtered Image x
54 52 57 55 56 52 51
50 49 51 50 52 53 58
51 204 52 52 0 57 60
48 50 51 49 53 59 63
49 51 52 55 58 64 67
50 54 57 60 63 67 70
51 55 59 62 65 69 72
Image f (x, y) Image f (x, y)
y y
24
Noise Removal Examples
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Image Result of 1
Corrupted Pass with a
by Salt and 3x3 Median
Pepper Noise Filter
Result of 2 Result of 3
Passes with Passes with
a 3x3 Median a 3x3 Median
Filter Filter
25
Max and Min Filter
Max Filter:
fˆ ( x, y) max {g ( s, t )}
( s ,t )S xy
Min Filter:
fˆ ( x, y) min {g ( s, t )}
( s ,t )S xy
Max filter is good for pepper noise or salt noise?
Min filter is good for pepper noise or salt noise?
26
Noise Corruption Example
Original Image x Filtered Image x
54 52 57 55 56 52 51
50 49 51 50 52 53 58
51 204 52 52 0 57 60
48 50 51 49 53 59 63
49 51 52 55 58 64 67
50 54 57 60 63 67 70
51 55 59 62 65 69 72
Image f (x, y) Image f (x, y)
y y
27
Noise Removal Examples (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Image Image
Corrupted Corrupted
by Pepper by Salt
Noise Noise
Result of Result of
Filtering Filtering
Above Above
with a 3x3 with a 3x3
Max Filter Min Filter
28
Midpoint Filter
Midpoint Filter:
ˆf ( x, y) 1 max {g ( s, t )} min {g ( s, t )}
2 ( s ,t )S xy ( s ,t )S xy
Good for random Gaussian and uniform noise.
29
Noise Corruption Example
Original Image x Filtered Image x
54 52 57 55 56 52 51
50 49 51 50 52 53 58
51 204 52 52 0 57 60
48 50 51 49 53 59 63
49 51 52 55 58 64 67
50 54 57 60 63 67 70
51 55 59 62 65 69 72
Image f (x, y) Image f (x, y)
y y
30
Alpha-Trimmed Mean Filter
Alpha-Trimmed Mean Filter:
1
fˆ ( x, y )
mn d
g ( s, t )
( s ,t )S xy
r
We delete the d/2 lowest and d/2 highest gray
levels.
So gr(s, t) represents the remaining mn – d pixels.
When such a filter can be useful?
Useful when a combination of Gaussian noise
and salt-and-pepper noise is present.
31
Noise Corruption Example
Original Image x Filtered Image x
54 52 57 55 56 52 51
50 49 51 50 52 53 58
51 204 52 52 0 57 60
48 50 51 49 53 59 63
49 51 52 55 58 64 67
50 54 57 60 63 67 70
51 55 59 62 65 69 72
Image f (x, y) Image f (x, y)
y y
32
Noise Removal Examples (cont…)
Image Image Further
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Corrupted Corrupted
by Uniform by Salt and
Noise Pepper Noise
Filtered by Filtered by
5x5 Arithmetic 5x5 Geometric
Mean Filter Mean Filter
Filtered by Filtered by
5x5 Median 5x5 Alpha-Trimmed
Filter Mean Filter
33
Adaptive Filters
The filters discussed so far are applied to an entire
image without any regard for how image
characteristics vary from one point to another.
The behaviour of adaptive filters changes
depending on the characteristics of the image
inside the filter region.
We will take a look at the adaptive median filter.
34
Adaptive Median Filtering
The median filter performs relatively well on
impulse noise as long as the spatial density of the
impulse noise is not large.
The adaptive median filter can handle much more
spatially dense impulse noise, and also performs
some smoothing for non-impulse noise.
The key insight in the adaptive median filter is that
the filter size changes depending on the
characteristics of the image.
35
Adaptive Median Filtering (cont…)
Remember that filtering looks at each original pixel
image in turn and generates a new filtered pixel
First examine the following notation:
– zmin = minimum grey level in Sxy 50 49 51
51 204 52
– zmax = maximum grey level in Sxy
48 50 51
– zmed = median of grey levels in Sxy
– zxy = grey level at coordinates (x, y)
– Smax =maximum allowed size of Sxy
36
Adaptive Median Filtering (cont…)
Level A: A1 = zmed – zmin
A2 = zmed – zmax
If A1 > 0 and A2 < 0, Go to level B
Else increase the window size
If window size ≤ repeat Smax level A
Else output zmed
Level B: B1 = zxy – zmin
B2 = zxy – zmax
If B1 > 0 and B2 < 0, output zxy
Else output zmed
37
Adaptive Median Filtering (cont…)
The key to understanding the algorithm is to
remember that the adaptive median filter has three
purposes:
– Remove impulse noise
– Provide smoothing of other noise
– Reduce distortion (e.g thinning or thickening of
object boundaries)
38
Adaptive Filtering Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Image corrupted by salt Result of filtering with a Result of adaptive
and pepper noise with 7x7 median filter median filtering with
probabilities Pa = Pb=0.25 Smax = 7
39
Periodic Noise
Typically arises due to
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
electrical or electromagnetic
interference.
Gives rise to regular noise
patterns in an image.
Frequency domain techniques
in the Fourier domain are most
effective at removing periodic
noise.
40
Band Reject Filters
Removing periodic noise from an image involves
removing a particular range of frequencies from
that image.
Band reject filters can be used for this purpose
An ideal band reject filter is given as follows:
W
1 if D(u, v) D0 2
W W
H (u, v) 0 if D0 D(u, v) D0
2 2
1 if D(u, v) D0 W
2
41
Band Reject Filters (cont…)
The ideal band reject filter is shown below, along
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
with Butterworth and Gaussian versions of the filter.
Ideal Band Butterworth Gaussian
Reject Filter Band Reject Band Reject
Filter (of order 1) Filter
42
Band Reject Filter Example
Image corrupted by Fourier spectrum of
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
sinusoidal noise corrupted image
Butterworth band Filtered image
reject filter
43
Other Image Degradations
Sometimes, degradation in an image is not due to
noise but due to events like motion blur, camera
lens defocus etc.
44
Inverse Filtering
If degradation can be modeled by a function h(x,y),
the simplest approach to restoration is inverse
filtering:
ˆf ( x, y ) g ( x, y )
h ( x, y )
where g(x,y) represents the degraded image.
If there is an additional noise degradation, the
restoration process is much more involved. It is
beyond the scope of our course.
45
Inverse Filtering
An example from MATLAB:
deconvwnr() commands applies
Wiener filter (reduces to inverse
filtering in te absence of noise).
Motion is modeled:
len=31; theta=11;
PSF=fspecial('motion',len,theta);
Deconvolution:
RestoredImage =
deconvwnr(BlurredImage,PSF);
46
Summary
We looked at image restoration for noise removal.
Restoration is slightly more objective than
enhancement.
Spatial domain techniques are particularly useful
for removing random noise.
Frequency domain techniques are particularly
useful for removing periodic noise.
Other types of image degradations and inverse
filtering.
47