5-1 Chapter 5: Neighborhood Processing Point processing: applies a function to each pixel...
-
Upload
benedict-harrington -
Category
Documents
-
view
215 -
download
0
Transcript of 5-1 Chapter 5: Neighborhood Processing Point processing: applies a function to each pixel...
5-1
Chapter 5: Neighborhood Processing
Point processing: applies a function to each
pixel
Neighborhood processing: applies a function
to a neighborhood of each pixel
5-2
○ Neighborhood (mask)
-- can have different shapes and sizes
5-3
○ Function + Mask = Filter
Filter
Output signalInput signal
5-4
2
2
( )
21( )
2
x x
g x e
11
( ) ( )2
/ 2 1/ 2
1( )
(2 ) | |
x-x x-x
xT
ng e
1D 2D
5-5
◎ Linear filter: linear combination of the gray
values in the mask
5-6
1 2
1 2
( , ) ( , ) ( , )
( 1, 2) ( 1, 2)
( 1, 1) ( 1, 1)
(1,2) ( 1, 2)
s t
p x y m s t p x s y t
m p x y
m p x y
m p x y
5-7
。 Example
1( )
9a b c d e f g h i
5-8
○ Processing near image boundaries
(a) Ignore the boundary(b) Pad with zeros(c) Copy boundary
○ Values outside the range 0-255
(a) Clip values(b) Scale values
5-9
◎ Convolution 1 D : ( ) ( )
( ) ( )
f x g d
f g x d
5-10
Discrete: ( , ) ( , )s t
f x s y t g s t
1 2
1 2
( , ) ( , )s t
p x s y t m s t
Linear filtering:
2 D: ( , ) ( , )f x y g d d
Compared with
5-11
( ) ( ) ( ) ( )f x g d f g x d
◎ Correlation
5-12
◎ Smoothing Filters
○ Averaging filters
Input 3X3 5X5 7X7
5-13
○ Gaussian filters
(1-D):
(2-D):
2 2
222
1( , )
2
x y
g x y e
2
2
( )
21( )
2
x x
g x e
5-14
Gaussian filters
Averaging filters
5-15
○ Separable filters 1 2( , ) ( ) ( )f x y f x f y2 2 2 2
2 2 2
x y x y
e e e
1/9 1/9 1/9 1/3
1/9 1/9 1/9 1/3 [1/3 1/3 1/3]
1/9 1/9 1/9 1/3
1 2 1 1
2 4 2 2 [1 - 2 1]
1 2 1 1
Laplacian filter
e.g.,
5-16
n × n filter:
2 (n × 1) filters: 2 multiplicationsn
2 multiplicationsn2 1 additionsn
2 2 additionsn
5-17
Frequency domain filters:
5-18
3-19
( ) exp( )nn
f x c jn x
/ 2
/ 2
1( )exp( ) ,
T
n Tc f x jn x dx
T
0 01
, ( ) / 222 [ ], 2 [ ]
n n n
n e n n m n
c a c a jb
a R c b I c
01
( ) / 2 cos sinn nn
f x a a n x b n x
The relationships between their coefficients
can be written in complex form
where
5-20
5-21
5-22
Frequency: a measure by which gray values change with distance
5-23
High pass filter Low pass filter
High frequency components, e.g., edges, noises
Low frequency components, e.g., regions
Spatialdomain
Frequency domain
Fouriertransform
5-24
High pass Low pass
Input image Fourier transform
5-25
High pass filter e.g., LoG
1 2 1
2 4 2
1 2 1
1/9 1/9 1/9
1/9 1/9 1/9
1/9 1/9 1/9
○ In spatial domain
Low pass filtere.g., Averaging filter
Output
5-26
◎ Edge Sharpening or Enhancement
○ Unsharp masking
5-27
。 Idea of unsharp masking
(a) Edge
(b) Blurred edge
(a) – k × (b)
5-28
。 Perform using a filter0 0 0 1/9 1/9 1/9
0 1 0 1/9 1/9 1/9
0 0 0 1/9 1/9 1/9
k
1 2
0 0 0 1/9 1/9 1/9
0 1 0 1/9 1/9 1/9
0 0 0 1/9 1/9 1/9
k k
。 Alternatives
(a)
(b) The averaging filter can be replaced with any low pass filters
5-29
。 Example:
(a) Original (b) Unsharp Masking
5-30
○ High-boost filter
high boost = A(original) – (low pass)
= A(original) – ((original) - (high pass)
= (A-1)(original) + (high pass)
。 Alternatives:
(a) (A/(A-1))(original) + (1/(A-1))((low pass)
(b) (A/(2A-1))(original) + ((1-A)/(2A-1))((low pass)
5-31
。 Example:(a) (A/(A-1))(original) + (1/(A-1))((low pass)
(b) (A/(2A-1))(original) + ((1-A)/(2A-1))((low pass)
5-32
◎ Non-linear smoothing filters
1 2 3 nx x x x ix
nx
: mask elements
。 Maximum filter:
1x。 Minimum filter:
5-33
。 Median filter
。 K-nearest neighbors (K-NN)
。 Geometric mean filter
。 Alpha-trimmed mean filter
i) Order elements
ii) Trim off m end elements
iii) Take mean
1/| |
( , )
( , )M
i j M
x i j
1
( ) /( 2 )n m
i
i m
x n m
/ 2nx
5-34
◎ Region of Interest Processing