non-linear filtering
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 PresentationTRANSCRIPT
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
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
Linear (averaging)
Input
Median
Median filters: example
filter width = 5
Linear (averaging)
Input
MedianDiscards
spike
Preservesjump exactly
at correctlocation
Median filters: example
filter width = 5
Linear (averaging)
Input
Median
Smooths spike
Blursjump
Median filter
3 x 3 median filter
Sharpens edges Destroys edge cusps and protrusions
Original
Keeps edges sharp Odd Man Out can destroy details
Median filter vs Gaussian
Gaussian
Eye has more detail.Blurrier edges
3 x 3 median filter
Median filter: summary
• Purpose– Smooth image without blurring boundaries
Input Median Filter
Median filter: summary
• Purpose– Smooth image without blurring boundaries
• Problem– Loses small details
Input Median Filter
Another approach: bilateral filter
Input Gaussian Smoothed
Another approach: bilateral filter
Input Gaussian Smoothed
[
OK to average these brightness values
Another approach: bilateral filter
Input Gaussian Smoothed
[
Don’t average these(brightness too different,
probably from different objects)
Another approach: bilateral filter
Input Gaussian Smoothed
• Bilateral smoothing: basic idea
– Ordinary smoothing…– But only sum over pixels with similar brightness
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
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
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)
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)
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)
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))
Another approach: bilateral filter
Input Bilateral Smoothing
• Bilateral smoothing: basic idea
– Ordinary smoothing…– But only sum over pixels with similar brightness
Another approach: bilateral filter
Input Bilateral Smoothing
• Bilateral smoothing: basic idea
– Ordinary smoothing…– But only sum over pixels with similar brightness
Smoothed
Another approach: bilateral filter
Input Bilateral Smoothing
• Bilateral smoothing: basic idea
– Ordinary smoothing…– But only sum over pixels with similar brightness
Not smoothed
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
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
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
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
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
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
Bilateral filter
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
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
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
…
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
…
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
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
…
Pattern detection with filters
• Gaussian filter– Detects blobs
• “Derivative” filter e.g., [-1/2 0 1/2]– Detects brightness jumps
• eye detector?
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
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
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
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
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
Normalized Correlation
• MATLAB demo (eye detection)
Detection with Normalized Correlation
• ProblemResult of normalized correlation
Suppose you want 3 best candidates for an eye…
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)
Detection with Normalized Correlation
• SolutionResult of normalized correlation
Only consider pixels with higher NC value than at all other “nearby” pixels
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
Detection with Normalized Correlation
• SolutionResult of normalized correlation
Result of NC and NonMax Suppression