non-linear filtering

47
Non-linear filtering Example: Median filter Replaces pixel value by median value over neighborhood Generates no new gray levels 2 2 2 2 I=(1 2 3 2 3 2 1) 3

Upload: morley

Post on 24-Feb-2016

40 views

Category:

Documents


2 download

DESCRIPTION

Non-linear filtering. Example: Median filter Replaces pixel value by median value over neighborhood Generates no new gray levels. Median filters. Advantage (?): the “odd-man-out” effect. e.g. 1,1,1,7,1,1,1,1  ?,1,1,1.1,1,1,?. Median filters: example. filter width = 5 . Input. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Non-linear filtering

Non-linear filtering

• Example: Median filter

• Replaces pixel value by median value over neighborhood

• Generates no new gray levels

I=(1 2 3 2 3 2 1)2 22 3 2

Page 2: Non-linear filtering

Median filters

Advantage (?): the “odd-man-out” effect

e.g.1,1,1,7,1,1,1,1

?,1,1,1.1,1,1,?

Page 3: Non-linear filtering

Median filters: example

filter width = 5

Linear (averaging)

Input

Median

Page 4: Non-linear filtering

Median filters: example

filter width = 5

Linear (averaging)

Input

MedianDiscards

spike

Preservesjump exactly

at correctlocation

Page 5: Non-linear filtering

Median filters: example

filter width = 5

Linear (averaging)

Input

Median

Smooths spike

Blursjump

Page 6: Non-linear filtering

Median filter

3 x 3 median filter

Sharpens edges Destroys edge cusps and protrusions

Original

Keeps edges sharp Odd Man Out can destroy details

Page 7: Non-linear filtering

Median filter vs Gaussian

Gaussian

Eye has more detail.Blurrier edges

3 x 3 median filter

Page 8: Non-linear filtering

Median filter: summary

• Purpose– Smooth image without blurring boundaries

Input Median Filter

Page 9: Non-linear filtering

Median filter: summary

• Purpose– Smooth image without blurring boundaries

• Problem– Loses small details

Input Median Filter

Page 10: Non-linear filtering

Another approach: bilateral filter

Input Gaussian Smoothed

Page 11: Non-linear filtering

Another approach: bilateral filter

Input Gaussian Smoothed

[

OK to average these brightness values

Page 12: Non-linear filtering

Another approach: bilateral filter

Input Gaussian Smoothed

[

Don’t average these(brightness too different,

probably from different objects)

Page 13: Non-linear filtering

Another approach: bilateral filter

Input Gaussian Smoothed

• Bilateral smoothing: basic idea

– Ordinary smoothing…– But only sum over pixels with similar brightness

Page 14: Non-linear filtering

Another approach: bilateral filter

Input Gaussian Smoothed

• Bilateral smoothing: basic idea

– Ordinary smoothing…– But only sum over pixels with similar brightness

Sum over all 3 pixels

Page 15: Non-linear filtering

Another approach: bilateral filter

Input Gaussian Smoothed

• Bilateral smoothing: basic idea

– Ordinary smoothing…– But only sum over pixels with similar brightness

Sum over all 3 pixels

Page 16: Non-linear filtering

Another approach: bilateral filter

Input Gaussian Smoothed

• Bilateral smoothing: basic idea

– Ordinary smoothing…– But only sum over pixels with similar brightness

Sum over all 3 pixels (similar brightness)

Page 17: Non-linear filtering

Another approach: bilateral filter

Input Gaussian Smoothed

• Bilateral smoothing: basic idea

– Ordinary smoothing…– But only sum over pixels with similar brightness

Don’t sum over 3rd pixel (too dark)

Page 18: Non-linear filtering

Another approach: bilateral filter

Input Gaussian Smoothed

• Bilateral smoothing: basic idea

– Ordinary smoothing…– But only sum over pixels with similar brightness

Don’t sum over 3rd pixel (too bright)

Page 19: Non-linear filtering

Another approach: bilateral filter

Input Gaussian Smoothed

• Bilateral smoothing: basic idea

– Ordinary smoothing…– But only sum over pixels with similar brightness

Sum over all 3 pixels (similar brightness))

Page 20: Non-linear filtering

Another approach: bilateral filter

Input Bilateral Smoothing

• Bilateral smoothing: basic idea

– Ordinary smoothing…– But only sum over pixels with similar brightness

Page 21: Non-linear filtering

Another approach: bilateral filter

Input Bilateral Smoothing

• Bilateral smoothing: basic idea

– Ordinary smoothing…– But only sum over pixels with similar brightness

Smoothed

Page 22: Non-linear filtering

Another approach: bilateral filter

Input Bilateral Smoothing

• Bilateral smoothing: basic idea

– Ordinary smoothing…– But only sum over pixels with similar brightness

Not smoothed

Page 23: Non-linear filtering

Another approach: bilateral filter

Input Bilateral Smoothing

• Bilateral smoothing: implementation

– Ordinary smoothing…– But only sum over pixels with similar brightness– Pixels with similar brightness weighted more

Page 24: Non-linear filtering

Bilateral filter• Weight pixel contributions by nearness in distance and

nearness in intensity

– Old: Gaussian smoothing

' '', '

, , ', 'ij i ji j

I w i j i j I

Page 25: Non-linear filtering

Bilateral filter• Weight pixel contributions by nearness in distance and

nearness in intensity

– Old: Gaussian smoothing

' '', '

, , ', 'ij i ji j

I w i j i j I 2 2

2' '

21' '

', '

D

i i j j

D e i ji j

N I

Page 26: Non-linear filtering

Bilateral filter• Weight pixel contributions by nearness in distance and

nearness in intensity

– Old: Gaussian smoothing

' '', '

, , ', 'ij i ji j

I w i j i j I

Normalization(so weights sum to 1)

2 2

2' '

21' '

', '

D

i i j j

D e i ji j

N I

Page 27: Non-linear filtering

Bilateral filter• Weight pixel contributions by nearness in distance and

nearness in intensity

– Old: Gaussian smoothing

– New: bilateral smoothing

' '', '

', 'ij i ji j

I w i i j j I 2 2

2' '

21' '

', '

D

i i j j

D e i ji j

N I

2 2 2

' '2 2

' '2 21 1

' '', '

ij i j

I D

I I i i j j

ij I e D e i ji j

I N N I

Page 28: Non-linear filtering

Bilateral filter

• Weight pixel contributions by nearness in distance and nearness in intensity

– Old: Gaussian smoothing

– New: bilateral smoothing

' '', '

', 'ij i ji j

I w i i j j I 2 2

2' '

21' '

', '

D

i i j j

D e i ji j

N I

2

2

2' '2

2' '21 21

' '', '

ij i

D

j

I

i i j j

ij D e i j

I I

ei

Ij

I N IN

Suppresses contributionfrom pixels with different brightness

Page 29: Non-linear filtering

Bilateral filter

Page 30: Non-linear filtering

Pattern detection with filters

• Biggest response to brightness patterns resembling them!

• Example: 1D correlation with mask

W I 1 0 1( )W w w w

Page 31: Non-linear filtering

Pattern detection with filters

• Biggest response to brightness patterns resembling them!

• Example: 1D correlation with mask Compute at position 3

W I 1 0 1( )W w w w

3W I

Page 32: Non-linear filtering

Pattern detection with filters

• Biggest response to brightness patterns resembling them!

• Example: 1D correlation with mask Compute at position 3

I1 I2 I3 I4 I5 I6Image (1D)

mask weights 1 0 1w w w

W I 1 0 1( )W w w w

3W I

Page 33: Non-linear filtering

Pattern detection with filters

• Biggest response to brightness patterns resembling them!

• Example: 1D correlation with mask Compute at position 3

I1 I2 I3 I4 I5 I6Image (1D)

mask weights 1 0 1w w w

1 2 0 3 1 4w I w I w I 3W I

W I 1 0 1( )W w w w

3W I

Page 34: Non-linear filtering

Pattern detection with filters

• Biggest response to brightness patterns resembling them!

• Example: 1D correlation with mask Compute at position 3

I1 I2 I3 I4 I5 I6Image (1D)

mask weights

Vector i

Vector w

2 3 4( )I I I

1 0 1( )w w w1 0 1w w w

3W I

W I 1 0 1( )W w w w

3W I

1 2 0 3 1 4w I w I w I

Page 35: Non-linear filtering

Pattern detection with filters

• Biggest response to brightness patterns resembling them!

• Example: 1D correlation with mask Compute at position 3

I1 I2 I3 I4 I5 I6Image (1D)

mask weights

Vector i

Vector w

dot product

2 3 4( )I I I

1 0 1( )w w w1 0 1w w w

1 2 0 3 1 4w I w I w I w i 3W I

W I 1 0 1( )W w w w

3W I

Page 36: Non-linear filtering

Pattern detection with filters

• Gaussian filter– Detects blobs

• “Derivative” filter e.g., [-1/2 0 1/2]– Detects brightness jumps

• eye detector?

Page 37: Non-linear filtering

Pattern detection with filters

• Summary: detect pattern (object) by correlating with similar mask

• Problems when lighting changes – Overall brightness can change between images

– Contrast may change

– Or both…

new oldI I c

new oldI k I

new oldI k I c

Page 38: Non-linear filtering

To improve detection: Compensate for changes in brightness and contrast

• Want to detect pattern Old

– Correlate image with

– Pattern “detected” wherever is large

P

P ' '''

ij kl k li k kj l l

P I P I

| |P I

Page 39: Non-linear filtering

To improve detection: Compensate for changes in brightness and contrast

• Want to detect pattern Old

– Correlate image with

– Pattern “detected” wherever is large

New: at each pixel (i,j)– Subtract average brightness (to eliminate problems from additive shifts)

Do weighted sum

P

P

' '', '

1'kl kl kl k lk l

P P P PN

' '', '

1'kl kl kl k lk l

I I I IN

' '''

ij kl k li k kj l l

P I P I

| |P I

' '''

' 'ij kl k li k kj l l

C P I

Page 40: Non-linear filtering

To improve detection: Compensate for changes in brightness and contrast

New: at each pixel (i,j)

– Subtract average brightness

Do weighted sum

– Normalize (avoids problems from contrast changes)

' '', '

1'kl kl kl k lk l

P P P PN

' '', '

1'kl kl kl k lk l

I I I IN

' '''

' 'ij kl k li k kj l l

C P I

' '

2

' ''

'

kl k l

ij

P IC

I

Page 41: Non-linear filtering

Normalized Correlation

,

1/ 2 1/ 22 2

, ,

( , ) , ,,

( , ) , ,

i jNC

i j i j

P i j P I x i y j I x yI x y

P i j P I x i y j I x y

Important: for each (x,y) (i.e., each pixel in result )

you must compute the average for window centered over (x,y) ,I x y

NCI

Page 42: Non-linear filtering

Normalized Correlation

• MATLAB demo (eye detection)

Page 43: Non-linear filtering

Detection with Normalized Correlation

• ProblemResult of normalized correlation

Suppose you want 3 best candidates for an eye…

Page 44: Non-linear filtering

Detection with Normalized Correlation

• ProblemResult of normalized correlation

Suppose you want 3 best candidates for an eye…

The three highest NCvalues are all here(at best eye position plus2 nearby pixels)

Page 45: Non-linear filtering

Detection with Normalized Correlation

• SolutionResult of normalized correlation

Only consider pixels with higher NC value than at all other “nearby” pixels

Page 46: Non-linear filtering

Detection with Normalized Correlation

• SolutionResult of normalized correlation

Only consider pixels with higher NC value than at all other “nearby” pixels (Non maximum suppression)

(Non Ma

Page 47: Non-linear filtering

Detection with Normalized Correlation

• SolutionResult of normalized correlation

Result of NC and NonMax Suppression