Image Processing EELE 54..

Download Report

Transcript Image Processing EELE 54..

Digital Image Processing
Image
Enhancement
Part IV
Nonlinear Filtering
• Nonlinear Filters
– Cannot be expressed as convolution
– Cannot be expressed as frequency shaping
• “Nonlinear” Means Everything (other than linear)
– Need to be more specific
– Often heuristic
– We will study some “nice” ones
Impulsive (Salt & Pepper) Noise
• Definition
– Each pixel in an image has a probability pa or pb of being
contaminated by a white dot (salt) or a black dot (pepper)
X: noise-free image, Y: noisy image
 255

Y (m, n)   0
 X (m, n)

with probability pa
with probability pb
with probability 1 - pa - pb
add salt & pepper noise
noisy pixels
clean pixels
Order-Statistics Filters
nonlinear spatial filters
response is based on ordering (ranking) the
pixels contained in the image area encompassed
by the filter
replacing of the center pixel with the value
determined by the ranking result
Median Filtering
Median filter
replaces the pixel value by the median value in the
neighborhood
The principal function is to force distinct gray level
points to be more like their neighbors.
excellent noise-reduction capabilities with less blurring
than linear smoothing filters
effective for impulse noise (salt-and-pepper noise)
Min: Set the pixel value to the minimum
in the neighbourhood
 Max: Set the pixel value to the maximum
in the neighbourhood

cf.) max filter → R = max {zk | k = 1,2,…,9}
min filter → R = min {z | k = 1,2,…,9}
Order-Statistics Filters
– Given a set of numbers
x  {x1 , x2 ,, x2 M 1}
max
value
Denote the OS as
xOS  {x(1) , x( 2) ,, x( 2 M 1) }
such that
x(1)  x( 2)    x( M 1)    x( 2 M 1)
min value
middle value
Median{x1 , x2 ,, x2 M 1}  x( M 1)
• Applying Median Filters
to Images
– Use sliding windows
(similar to spatial linear filters)
– Typical windows:
3x3, 5x5, 7x7, other shapes ……
Median Filters
original
noisy (pa = pb = 0.1)
median filtered 3x3 window
median filtered 5x5 window
From MATLAB sample images
Iterative Median Filters
• Idea: repeatedly apply median filters
1 time
2 times
3 times
From [Gonzalez & Woods]
Switching Median Filters
• Motivation
– Regular median filters change both “bad” and “good” pixels
• Idea
– Detect/classify “bad” and “good” pixels
– Filter “bad” pixels only
From [Wang & Zhang]
Switching Median Filters
original
noisy (pa = pb = 0.1)
regular 5x5 median filtered
switching 5x5 median filtered
From MATLAB sample images
Order Statistics (OS) Filters
• Recall Order Statistics:
For
x  {x1 , x2 ,, x2 M 1}
OS
xOS  {x(1) , x( 2) ,, x( 2 M 1) }
such that
x(1)  x( 2)    x( M 1)    x( 2 M 1)
• OS filter: General Form
OS {x1 , x2 ,, x2 M 1} 
• Special Cases
2 M 1
w x
i 1
i (i )
2 M 1
where
w
i 1
i
1
Min{x1 , x2 ,, x2 M 1}  x(1)
{wi }  {1,0,0,,0}
Max{x1 , x2 ,, x2 M 1}  x( 2 M 1)
{wi }  {0,0,0,,1}
Median{x1 , x2 ,, x2 M 1}  x( M 1)
{wi }  {0,0,1,,0}
(M+1)-th
Order Statistics (OS) Filters
• Note: An OS Filter is Uniquely Defined by {wi}
• Example 1:
{wi }  {0,,1 / 4,1 / 2,1 / 4,,0}
M-th
then
(M+2)-th
OS {x1 , x2 ,, x2 M 1}  0.25 x( M )  0.5 x( M 1)  0.25 x( M  2)
• Example 2:
then
(M+1)-th
{wi }  {1,1,,1} /( 2M  1)
OS {x1 , x2 ,, x2 M 1} 
2 M 1

i 1
1
x(i )
2M  1
 Mean{x(i ) , i  1,,2M  1}  Mean{xi , , i  1,,2M  1}
Examples
• A 4x4 grayscale image is given by
impulse?
5
6
7
8
0
6
7
8
5
6 15 8
5
6
7
impulse?
8
1) Filter the image with a 3x3 median filter, after zeropadding at the image borders
0
0
0
0
0
0
0
5
6
7
8
0
0
0
6
7
8
0
0
5
6
0
5
6
7
7
0
5
6
7
7
8
0
0
5
6
0
0
0
5
6
7
8
0
6
7
8
5
6 15 8
0
5
6 15 8
5
6
0
5
6
7
0
0
0
0
7
8
zero-padding
median
filtering
Examples
2) Filter the image with a 3x3 median filter, after replicatepadding at the image borders
replicate
-padding
5
5
6
7
8
8
5
5
6
7
8
8
0
0
6
7
8
8
6
7
8
5
6
7
8
8
5
6
7
8
8
8
5
6
7
8
8
8
6
7
8
0
6
7
8
5
6 15 8
5
5
6 15 8
5
6
5
5
6
7
5
5
6
7
7
8
median
filtering
5
5
impulse cleaned!
Examples
3) Filter the image with a 3x3 OS filter, after replicatepadding at the image borders. The weighting factors of
the OS filter are given by
{wi | i = 1, …, 9} = {0, 0, 0, ¼, ½, ¼, 0, 0, 0}
replicate
-padding
5
5
6
7
8
8
5
5
6
7
8
8
0
0
6
7
8
8
6
7
8
5
6
7.25
8
8
5
6
7.25
8
8
8
5
6
7.25
8
8
8
6
7
8
0
6
7
8
5
6 15 8
5
5
6 15 8
5
6
5
5
6
7
5
5
6
7
7
8
OS
filtering
5
5
Gradient




the term gradient is used for a gradual blend of colour which can
be considered as an even gradation from low to high values
At each image point, the gradient vector points in the direction of
largest possible intensity increase,
the length of the gradient vector corresponds to the rate of
change in that direction.
Two types of gradients, with blue arrows to indicate the direction
of the gradient
Sobel operators
Represents a rather inaccurate approximation of
the image gradient
The operator calculates the gradient of the image
intensity at each point
Giving the direction of the largest possible
increase from light to dark and the rate of change
in that direction
The result therefore shows how "abruptly" or
"smoothly" the image changes at that point
Sobel Example
Sobel Example
Grayscale
image of a
brick wall & a
bike rack
scale image
of a brick wall
& a bike rack
Combining Spatial Enhancement
Methods
Successful image
enhancement is
typically not achieved
using a single operation
Rather we combine a
range of techniques in
order to achieve a final
result
This example will focus
on enhancing the bone
scan to the right
Combining Spatial Enhancement
Methods
(a)
Laplacian filter
bone scan (a)
of
(b)
Sharpened version of
bone scan achieved
(c)
by subtracting (a)
Sobel filter of bone
and (b)
scan (a)
(d)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Combining Spatial Enhancement
Methods
(h)
Result of applying a
The product of (c)
and (e) which will be
used as a mask
(e)
power-law trans. to
Sharpened image (g)
which is sum of (a)
(g)
and (f)
Image (d) smoothed with
a 5*5 averaging filter
(f)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Combining Spatial Enhancement
Methods

Compare the original and final images
assignments
Chapter 3
 1, 6, 10, 12, 18, 22, 23.
