chapter 5: neighborhood processing

34
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

Upload: lee-hicks

Post on 02-Jan-2016

42 views

Category:

Documents


10 download

DESCRIPTION

Chapter 5: Neighborhood Processing. Point processing: applies a function to each pixel Neighborhood processing: applies a function to a neighborhood of each pixel. ○ Neighborhood ( mask ). -- can have different shapes and sizes. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Chapter 5: Neighborhood  Processing

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

Page 2: Chapter 5: Neighborhood  Processing

5-2

○ Neighborhood (mask)

-- can have different shapes and sizes

Page 3: Chapter 5: Neighborhood  Processing

5-3

○ Function + Mask = Filter

Filter

Output signalInput signal

Page 4: Chapter 5: Neighborhood  Processing

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

Page 5: Chapter 5: Neighborhood  Processing

5-5

◎ Linear filter: linear combination of the gray

values in the mask

Page 6: Chapter 5: Neighborhood  Processing

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

Page 7: Chapter 5: Neighborhood  Processing

5-7

。 Example

1( )

9a b c d e f g h i

Page 8: Chapter 5: Neighborhood  Processing

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

Page 9: Chapter 5: Neighborhood  Processing

5-9

◎ Convolution 1 D : ( ) ( )

( ) ( )

f x g d

f g x d

Page 10: Chapter 5: Neighborhood  Processing

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

Page 11: Chapter 5: Neighborhood  Processing

5-11

( ) ( ) ( ) ( )f x g d f g x d

◎ Correlation

Page 12: Chapter 5: Neighborhood  Processing

5-12

◎ Smoothing Filters

○ Averaging filters

Input 3X3 5X5 7X7

Page 13: Chapter 5: Neighborhood  Processing

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

Page 14: Chapter 5: Neighborhood  Processing

5-14

Gaussian filters

Averaging filters

Page 15: Chapter 5: Neighborhood  Processing

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.,

Page 16: Chapter 5: Neighborhood  Processing

5-16

n × n filter:

2 (n × 1) filters: 2 multiplicationsn

2 multiplicationsn2 1 additionsn

2 2 additionsn

Page 17: Chapter 5: Neighborhood  Processing

5-17

Frequency domain filters:

Page 18: Chapter 5: Neighborhood  Processing

5-18

Page 19: Chapter 5: Neighborhood  Processing

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

Page 20: Chapter 5: Neighborhood  Processing

5-20

Page 21: Chapter 5: Neighborhood  Processing

5-21

Page 22: Chapter 5: Neighborhood  Processing

5-22

Frequency: a measure by which gray values change with distance

Page 23: Chapter 5: Neighborhood  Processing

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

Page 24: Chapter 5: Neighborhood  Processing

5-24

High pass Low pass

Input image Fourier transform

Page 25: Chapter 5: Neighborhood  Processing

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

Page 26: Chapter 5: Neighborhood  Processing

5-26

◎ Edge Sharpening or Enhancement

○ Unsharp masking

Page 27: Chapter 5: Neighborhood  Processing

5-27

。 Idea of unsharp masking

(a) Edge

(b) Blurred edge

(a) – k × (b)

Page 28: Chapter 5: Neighborhood  Processing

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

Page 29: Chapter 5: Neighborhood  Processing

5-29

。 Example:

(a) Original (b) Unsharp Masking

Page 30: Chapter 5: Neighborhood  Processing

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)

Page 31: Chapter 5: Neighborhood  Processing

5-31

。 Example:(a) (A/(A-1))(original) + (1/(A-1))((low pass)

(b) (A/(2A-1))(original) + ((1-A)/(2A-1))((low pass)

Page 32: Chapter 5: Neighborhood  Processing

5-32

◎ Non-linear smoothing filters

1 2 3 nx x x x ix

nx

: mask elements

。 Maximum filter:

1x。 Minimum filter:

Page 33: Chapter 5: Neighborhood  Processing

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

Page 34: Chapter 5: Neighborhood  Processing

5-34

◎ Region of Interest Processing