Overview
Image restoration
Image denoising
Image deblurring
Image enhancement
Spatial domain
Frequency domain
Image interpolation
Theme: bad-looking images good-looking images
1
Image Denoising
Introduction
Impulse noise removal
Median filtering
Additive white Gaussian noise removal
2D convolution and DFT
Periodic noise removal
Band-rejection and Notch filter
2
Introduction
Where does noise come from?
Sensor (e.g., thermal or electrical
interference)
Environmental conditions (rain, snow etc.)
Why do we want to denoise?
Visually unpleasant
Bad for compression
Bad for analysis
3
Noisy Image Examples
thermal interference electrical interference
4
Noise Modeling
Simplified assumptions
Noise is independent of signal
Noise types
Independent of spatial location
Impulse noise
Additive white Gaussian noise
Spatially dependent
Periodic noise
5
Noise Removal Techniques
Linear filtering
Nonlinear filtering
Recall
Linear system
6
Image Denoising
Introduction
Impulse noise removal
Median filtering
Additive white Gaussian noise removal
2D convolution and DFT
Periodic noise removal
Band-rejection and Notch filter
7
Impulse Noise (salt-pepper
Noise)
Definition
Each pixel in an image has the probability of p/2 (0<p<1) being
contaminated by either a white dot (salt) or a black dot (pepper)
255 with probability of p/2
noisy pixels
Y (i, j ) 0 with probability of p/2
X (i, j ) with probability of 1-p clean pixels
1 i H ,1 j W X: noise-free image, Y: noisy image
Note: in some applications, noisy pixels are not simply black or white,
which makes the impulse noise removal problem more difficult
8
Numerical Example
P=0.1
128 128 128 128 128 128 128 128 128 128 128 128 255 0 128 128 128 128 128 128
128 128 128 128 128 128 128 128 128 128 128 128 128 128 0 128 128 128 128 0
128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128
128 128 128 128 128 128 128 128 128 128 128 128 0 128 128 128 128 128 128 128
128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128
128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128
128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128
128 128 128 128 128 128 128 128 128 128 0 128 128 128 128 255 128 128 128 128
128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 255
128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 255 128 128
X Y
Noise level p=0.1 means that approximately 10% of pixels are contaminated by
salt or pepper noise (highlighted by red color)
9
MATLAB Command
>Y = IMNOISE(X,'salt & pepper',p)
Notes:
The intensity of input images is assumed to be normalized to [0,1].
If X is double, you need to do normalization first, i.e., X=X/255;
If X is uint8, MATLAB would do the normalization automatically
The default value of p is 0.05 (i.e., 5 percent of pixels are contaminated)
imnoise function can produce other types of noise as well (you need to
change the noise type ‘salt & pepper’)
10
Impulse Noise Removal Problem
filtering denoised ^
X
algorithm image
^
Can we make the denoised image X as close
Noisy image Y
to the noise-free image X as possible?
11
Median Operator
Given a sequence of numbers {y1,…,yN}
Mean: average of N numbers
Min: minimum of N numbers
Max: maximum of N numbers
Median: half-way of N numbers
Example y [50,0,52,255,54,55,56]
sorted [0,50,52,54,55,56,255]
y
median( y ) 54
12
1D Median Filtering
y(n)
… …
W=2T+1
xˆ (n) median[ y (n T ),..., y (n),..., y (n T )]
MATLAB command: x=median(y(n-T:n+T));
Note: median operator is nonlinear
13
Numerical Example
T=1:
y [50,0,52,255,54,55,56]
Boundary y [50,50,0,52,255,54,55,56,56]
Padding
ˆ
x [50,50,52,54,54,55,55]
14
2D Median Filtering
x(m,n)
W: (2T+1)-by-(2T+1) window
xˆ (m, n) median[ y (m T , n T ),..., y (m T , n T ),...,
y (m, n),..., y (m T , n T ),..., y (m T , n T )]
MATLAB command: x=medfilt2(y,[2*T+1,2*T+1]);
15
Numerical Example
225 225 225 226 226 226 226 226 0 225 225 226 226 226 226 226
225 225 255 226 226 226 225 226 225 225 226 226 226 226 226 226
226 226 225 226 0 226 226 255 225 226 226 226 226 226 226 226
255 226 225 0 226 226 226 226 226 226 225 225 226 226 226 226
225 255 0 225 226 226 226 255 225 225 225 225 226 226 226 226
255 225 224 226 226 0 225 226 225 225 225 226 226 226 226 226
226 225 225 226 255 226 226 228 225 225 225 226 226 226 226 226
226 226 225 226 226 226 226 226 226 226 226 226 226 226 226 226
^
Y X
Sorted: [0, 0, 0, 225, 225, 225, 226, 226, 226]
16
Image Example
P=0.1
denoised ^
Noisy image Y X
image
3-by-3 window
17
Image Example (Con’t)
noisy
clean
(p=0.2)
3-by-3 window 5-by-5 window
18
Reflections
What is good about median operation?
Since we know impulse noise appears as
black (minimum) or white (maximum) dots,
taking median effectively suppresses the
noise
What is bad about median operation?
It affects clean pixels as well
Noticeable edge blurring after median
filtering
19
Idea of Improving Median Filtering
Can we get rid of impulse noise without
affecting clean pixels?
Yes, if we know where the clean pixels are
or equivalently where the noisy pixels are
How to detect noisy pixels?
They are black or white dots
20
Median Filtering with Noise Detection
Noisy image Y
Median filtering
x=medfilt2(y,[2*T+1,2*T+1]);
Noise detection
C=(y==0)|(y==255);
Obtain filtering results
xx=c.*x+(1-c).*y;
21
Image Example
noisy
clean
(p=0.2)
w/o with
noise noise
detection detection
22