Noise Reduction Image Restoration
Image Restoration :
Noise Reduction
Image degradation /
restoration model
Gaussian Noise
Gaussian Noise : Matlab
t_gaus = imnoise (t, ‘gaussian’);
imshow(t_gaus);
TRY !!
Salt and Pepper Noise
Salt and Pepper Noise :
MATLAB
t_sp = imnoise (t, ‘salt & pepper’);
imshow(t_sp);
TRY !!
Other Additive Noise Models
• Rayleigh Noise
( z a ) 2 / b
2
p ( z ) ( z a)e
b
0
for z �a
for z a
• Gamma(Erlang) Noise
• Exponential Noise
p ( z ) ae az
for
z �0
=0
for
z0
• Uniform Noise
• Impulse Noise
Other Additive Noises
Other Additive Noises
Periodic Noise
Noise components
Periodic noise can be reduced in
via frequency domain
Are generated due to electrical or electromechanical interference during
image acquisition
Periodic Noise : MATLAB
tw = imread(filename);
t = rgb2gray(tw);
s = size(t);
[x,y] = meshgrid(1:s(1), 1:s(2));
p = sin(x/3+y/5)+1;
t_pn = (im2double(t)+p’/2)/2;
imshow(t_pn);
TRY !!
Restoration by
Spatial Filtering
Rank-Order Filter
• Sort the intensities within the mask.
• Choose the intensity at ith position as output.
10
20
10
15
5
5
10
13
5
0
20
11
20
15
5
10
8
0
0
10
10
20
15
0
10
Min. filter
Sort intensity
Median filter
Max. filter
Rank-Order Filter
Rank-Order Filter
• Max filter = mengambil pixel dengan nilai tinggi
• Min filter = mengambil pixel dengan nilai rendah
Rank-Order Filter : Max Filter
• Output pixel is the maximum intensity of the pixels within the
mask. (find brightest point)
BEFORE
Image corrupted by pepper noise
AFTER
Rank-Order Filter : Min Filter
• Output pixel is the minimum intensity of the pixels within the
mask. (find darkest point)
BEFORE
Image corrupted by salt noise
AFTER
Rank-Order Filter : Median
Filter
-- Repeated passes of median
filter tend to blur the image.
-- Keep the number of passes
as low as possible.
Rank-Order Filter :
Median Filter
• Output pixel is the midintensity of the pixels within
the mask (the median
intensity).
• Adaptive median filter
memiliki tujuan ganda yaitu
menghapus impuls noise
pada gambar dan
mengurangi distorsi pada
gambar.
Rank-Order Filter : Median
Filter
BEFORE
AFTER
3x3 Kernel
Rank-Order Filtering:
MATLAB
• Command: ordfilt2
• Syntax: ordfilt2(image, order, domain); medfilt2(image);
• image : input image
• order : which order of the sorted intensity (minimum to
maximum value) taken as output
• domain : matrix indicating the neighborhood.
1 : pixels in the neighbor.
0 : pixels not in the neighbor
E.g. cmin = ordfilt2(image, 1, ones(3,3));
Try to restore Salt
and Pepper Noise
by Median Filter !!
Mean Filters
Arithmetic & Geometric
Mean Filters
Arithmetic & Geometric
Mean Filter
Good Results of Geometric Mean Filter
BEFORE
Image corrupted by Gaussian noise with
variance = 300, mean = 0
AFTER
Mean Filter :
Bad Results of Geometric Mean Filter
BEFORE
Image corrupted by pepper noise with
probability = 0.4
AFTER
Mean Filters
Harmonic
Mean Filters
Contraharmonic
Mean Filters
Good Results of Contraharmonic Mean Filter
Pepper noise
Salt noise
Mean Filters
Bad Results of Contraharmonic Mean Filter
• Arithmetic mean filter and geometric mean filter are well suited for
random noise such as Gaussian noise
• Contraharmonic mean filter is well suited for impulse noise
• Disadvantage: must know pepper noise or salt noise in advance
Order-statistic Filters
Order-statistic Filters
Alpha-Trimmed Mean Filter
• Output is the mean of the data after removing the first d/2
and the last d/2 ordered data.
10
20
10
15
5
0
0
5
10
13
5
0
20
11
20
15
5
10
8
0
0
10
10
20
15
0
10
8
10
d =2
Trim the data by 2.
(1 from the top.
1 from the bottom.)
Sort intensity 11 Output = average
intensity of the
13 remaining data.
= 9.5
15
20
Order-statistic Filters
Effect of Alpha-Trimmed Mean Filter
BEFORE
Image corrupted by salt-and-pepper
noise with variance = 200, mean = 0
AFTER
Trim size = 2, mask size =1
-High level of noise large filter
-Median and alphatrimmed filter performed
better
- Alpha-trimmed did better
than median filter
Periodic Noise Reduction
Frequency Domain Filtering Band Reject Filters (Selective
Filter)
• Ideal Band-Reject Filters
• -D(u,v) =distance from the origin
W of the centered freq. rectangle
H (u , v) 1
if
D(u, v) D0
2
• -W =width of the band
W
W
0 center
if ofD0the
band.
�D(u , v) �D0
• -D0=Radial
2
2
1
if
D(u, v) D0
W
2
Periodic Noise Reduction
Frequency Domain Filtering Band Reject Filters
• Butterworth Band-Reject Filter of Order n
H (u, v)
1
2n
� D(u , v)W �
1 � 2
2 �
D
(
u
,
v
)
D
0 �
�
• Gaussian and-Reject Filter
2
H (u, v) 1 e
1 �D 2 ( u , v ) D02 �
�
�
2 � D ( u ,v )W �
Periodic Noise Reduction
Frequency Domain Filtering Band Reject Filters
Periodic Noise Reduction
Frequency Domain Filtering Band Pass Filters
• Opposite operation of a band-reject filter
H bp 1 H br (u , v )
Periodic Noise Reduction
Frequency Domain Filtering Notch Filters
• Rejects (or passes) frequencies in predefined neighborhoods
about a center frequency
Must appear in
symmetric pairs about
the origin.
Butterworth
Ideal
Gaussian
Periodic Noise Reduction
Frequency Domain Filtering Notch Filters
• Ideal Notch Filters
Center
frequency
components
H (u, v) 0
1
if
D1 (u, v) �D0
or
D2 (u, v) �D0
otherwise
1/ 2
2
2
�
D1 (u, v) �
(
u
M
/
2
u
)
(
v
N
/
2
v
)
0
0
�
�
and
2 1/ 2
D2 (u , v) �
(u M / 2 u0 ) (v N / 2 v0 ) �
�
�
2
Shift with respect
to the center
Notch pass filter
Horizontal lines of the
noise pattern I can be
seen
Tugas
• Cari tahu bagaimana cara menghilangkan periodic noise
menggunakan band-reject filter, band-pass filter atau notch
filter pada MATLAB.
• Simulasikan dan analisis hasilnya
Noise Reduction
Image degradation /
restoration model
Gaussian Noise
Gaussian Noise : Matlab
t_gaus = imnoise (t, ‘gaussian’);
imshow(t_gaus);
TRY !!
Salt and Pepper Noise
Salt and Pepper Noise :
MATLAB
t_sp = imnoise (t, ‘salt & pepper’);
imshow(t_sp);
TRY !!
Other Additive Noise Models
• Rayleigh Noise
( z a ) 2 / b
2
p ( z ) ( z a)e
b
0
for z �a
for z a
• Gamma(Erlang) Noise
• Exponential Noise
p ( z ) ae az
for
z �0
=0
for
z0
• Uniform Noise
• Impulse Noise
Other Additive Noises
Other Additive Noises
Periodic Noise
Noise components
Periodic noise can be reduced in
via frequency domain
Are generated due to electrical or electromechanical interference during
image acquisition
Periodic Noise : MATLAB
tw = imread(filename);
t = rgb2gray(tw);
s = size(t);
[x,y] = meshgrid(1:s(1), 1:s(2));
p = sin(x/3+y/5)+1;
t_pn = (im2double(t)+p’/2)/2;
imshow(t_pn);
TRY !!
Restoration by
Spatial Filtering
Rank-Order Filter
• Sort the intensities within the mask.
• Choose the intensity at ith position as output.
10
20
10
15
5
5
10
13
5
0
20
11
20
15
5
10
8
0
0
10
10
20
15
0
10
Min. filter
Sort intensity
Median filter
Max. filter
Rank-Order Filter
Rank-Order Filter
• Max filter = mengambil pixel dengan nilai tinggi
• Min filter = mengambil pixel dengan nilai rendah
Rank-Order Filter : Max Filter
• Output pixel is the maximum intensity of the pixels within the
mask. (find brightest point)
BEFORE
Image corrupted by pepper noise
AFTER
Rank-Order Filter : Min Filter
• Output pixel is the minimum intensity of the pixels within the
mask. (find darkest point)
BEFORE
Image corrupted by salt noise
AFTER
Rank-Order Filter : Median
Filter
-- Repeated passes of median
filter tend to blur the image.
-- Keep the number of passes
as low as possible.
Rank-Order Filter :
Median Filter
• Output pixel is the midintensity of the pixels within
the mask (the median
intensity).
• Adaptive median filter
memiliki tujuan ganda yaitu
menghapus impuls noise
pada gambar dan
mengurangi distorsi pada
gambar.
Rank-Order Filter : Median
Filter
BEFORE
AFTER
3x3 Kernel
Rank-Order Filtering:
MATLAB
• Command: ordfilt2
• Syntax: ordfilt2(image, order, domain); medfilt2(image);
• image : input image
• order : which order of the sorted intensity (minimum to
maximum value) taken as output
• domain : matrix indicating the neighborhood.
1 : pixels in the neighbor.
0 : pixels not in the neighbor
E.g. cmin = ordfilt2(image, 1, ones(3,3));
Try to restore Salt
and Pepper Noise
by Median Filter !!
Mean Filters
Arithmetic & Geometric
Mean Filters
Arithmetic & Geometric
Mean Filter
Good Results of Geometric Mean Filter
BEFORE
Image corrupted by Gaussian noise with
variance = 300, mean = 0
AFTER
Mean Filter :
Bad Results of Geometric Mean Filter
BEFORE
Image corrupted by pepper noise with
probability = 0.4
AFTER
Mean Filters
Harmonic
Mean Filters
Contraharmonic
Mean Filters
Good Results of Contraharmonic Mean Filter
Pepper noise
Salt noise
Mean Filters
Bad Results of Contraharmonic Mean Filter
• Arithmetic mean filter and geometric mean filter are well suited for
random noise such as Gaussian noise
• Contraharmonic mean filter is well suited for impulse noise
• Disadvantage: must know pepper noise or salt noise in advance
Order-statistic Filters
Order-statistic Filters
Alpha-Trimmed Mean Filter
• Output is the mean of the data after removing the first d/2
and the last d/2 ordered data.
10
20
10
15
5
0
0
5
10
13
5
0
20
11
20
15
5
10
8
0
0
10
10
20
15
0
10
8
10
d =2
Trim the data by 2.
(1 from the top.
1 from the bottom.)
Sort intensity 11 Output = average
intensity of the
13 remaining data.
= 9.5
15
20
Order-statistic Filters
Effect of Alpha-Trimmed Mean Filter
BEFORE
Image corrupted by salt-and-pepper
noise with variance = 200, mean = 0
AFTER
Trim size = 2, mask size =1
-High level of noise large filter
-Median and alphatrimmed filter performed
better
- Alpha-trimmed did better
than median filter
Periodic Noise Reduction
Frequency Domain Filtering Band Reject Filters (Selective
Filter)
• Ideal Band-Reject Filters
• -D(u,v) =distance from the origin
W of the centered freq. rectangle
H (u , v) 1
if
D(u, v) D0
2
• -W =width of the band
W
W
0 center
if ofD0the
band.
�D(u , v) �D0
• -D0=Radial
2
2
1
if
D(u, v) D0
W
2
Periodic Noise Reduction
Frequency Domain Filtering Band Reject Filters
• Butterworth Band-Reject Filter of Order n
H (u, v)
1
2n
� D(u , v)W �
1 � 2
2 �
D
(
u
,
v
)
D
0 �
�
• Gaussian and-Reject Filter
2
H (u, v) 1 e
1 �D 2 ( u , v ) D02 �
�
�
2 � D ( u ,v )W �
Periodic Noise Reduction
Frequency Domain Filtering Band Reject Filters
Periodic Noise Reduction
Frequency Domain Filtering Band Pass Filters
• Opposite operation of a band-reject filter
H bp 1 H br (u , v )
Periodic Noise Reduction
Frequency Domain Filtering Notch Filters
• Rejects (or passes) frequencies in predefined neighborhoods
about a center frequency
Must appear in
symmetric pairs about
the origin.
Butterworth
Ideal
Gaussian
Periodic Noise Reduction
Frequency Domain Filtering Notch Filters
• Ideal Notch Filters
Center
frequency
components
H (u, v) 0
1
if
D1 (u, v) �D0
or
D2 (u, v) �D0
otherwise
1/ 2
2
2
�
D1 (u, v) �
(
u
M
/
2
u
)
(
v
N
/
2
v
)
0
0
�
�
and
2 1/ 2
D2 (u , v) �
(u M / 2 u0 ) (v N / 2 v0 ) �
�
�
2
Shift with respect
to the center
Notch pass filter
Horizontal lines of the
noise pattern I can be
seen
Tugas
• Cari tahu bagaimana cara menghilangkan periodic noise
menggunakan band-reject filter, band-pass filter atau notch
filter pada MATLAB.
• Simulasikan dan analisis hasilnya