Image Filtering - Vision Labsvision.psych.umn.edu/.../Papers/Lec07ImageFiltering.pdf ·...

Preview:

Citation preview

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

Image Filtering

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

Topics

• Filtering as a linear transform

• Fourier Transform

• Filtering as feature finding

• Filtering for target detection

• Edge detection

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

For a filter size N by M,Rij = HuvFi−u, j−v

v=1:M∑

u=1:N∑

Convolution• Represent these weights as an

image, H

• H is usually called the kernel

• Operation is called convolution• Properties:

• Convolution is commutative.

• Convolution is associative.

• Convolution is distributive.

• Result is:

• Notice the order ofindices– all examples can be put

in this form

– it’s a result of thederivation expressing anyshift-invariant linearoperator as aconvolution.

Rij = Hi−u, j−vFuvu,v∑

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

Example: Smoothing by Averaging

Smoothing with a Gaussian• Smoothing with an average

actually doesn’t compare atall well with a defocussedlens– Most obvious difference is

that a single point of lightviewed in a defocussed lenslooks like a fuzzy blob; butthe averaging process wouldgive a little square.

• A Gaussian gives a goodmodel of a fuzzy blob

For a filter size N by M,Rij = HuvFi−u, j−v

v=1:M∑

u=1:N∑

exp −x2 + y2

2σ2

An Isotropic Gaussian

• The picture shows asmoothing kernelproportional to

(which is a reasonable model ofa circularly symmetric fuzzyblob)

H ~

Smoothing with a Gaussian

Differentiation and convolution

• Recall

• Now this is linear andshift invariant, so mustbe the result of aconvolution.

• We could approximate thisas

• This is a convolution: ( butit’s not a very good way to dothings, as we shall see)

∂f∂x

= limε→0

f x + ε, y( )ε

−f x, y( )ε

∂f∂x

≈f xn+1,y( )− f xn , y( )

Δx

∂h∂x

≈ hi+1, j − hi−1, j ⇒∂h∂x

= Di−u, j−vv∑

u∑ Fu,v

D =

0 0 01 0 −10 0 0

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

Filtering as a Linear Transform

h = 1 4 6 4 1

F =

F convolved with H = ?

101 101 112 96 124 167 158 134 128 115 114 107 95 149 64 75117 122 115 114 115 164 156 132 134 128 149 129 139 178 89 52144 147 139 128 122 162 153 135 131 129 168 152 135 149 154 135155 163 171 126 124 144 143 134 127 127 162 145 150 140 131 127133 149 153 111 122 150 140 130 129 138 149 159 149 150 159 158148 159 133 109 118 152 141 131 127 131 143 166 169 157 149 148143 144 121 106 118 151 144 130 127 135 134 152 171 173 167 163141 147 115 105 129 149 143 133 128 136 140 145 154 171 177 179145 141 118 115 142 151 150 143 131 137 143 139 148 157 168 175145 137 122 134 155 163 153 147 132 124 132 147 149 154 166 166152 141 128 145 165 171 166 152 138 124 128 147 164 159 165 164153 159 130 157 175 183 182 161 144 129 139 135 159 169 176 167161 147 127 156 178 192 183 160 143 137 152 129 158 158 178 178157 142 114 129 161 168 163 141 120 139 148 125 168 172 162 179157 152 70 87 129 139 129 103 67 63 100 98 175 174 166 167157 155 116 68 71 83 77 56 94 136 142 169 177 172 176 163

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

1 4 6 4 1 0 0 0 0 0 0 0 0 0 0 00 1 4 6 4 1 0 0 0 0 0 0 0 0 0 00 0 1 4 6 4 1 0 0 0 0 0 0 0 0 00 0 0 1 4 6 4 1 0 0 0 0 0 0 0 00 0 0 0 1 4 6 4 1 0 0 0 0 0 0 00 0 0 0 0 1 4 6 4 1 0 0 0 0 0 00 0 0 0 0 0 1 4 6 4 1 0 0 0 0 00 0 0 0 0 0 0 1 4 6 4 1 0 0 0 00 0 0 0 0 0 0 0 1 4 6 4 1 0 0 00 0 0 0 0 0 0 0 0 1 4 6 4 1 0 00 0 0 0 0 0 0 0 0 0 1 4 6 4 1 00 0 0 0 0 0 0 0 0 0 0 1 4 6 4 1

F’ = H*F

H =

H*F*H'

x & y filtering

y filtering

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

Image Synthesis with Fourier Basis

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005F here means the transformed function

F here means fourier transform

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

Finite differences

Noise• Simplest noise model

– independent stationaryadditive Gaussian noise

– the noise value at eachpixel is given by anindependent draw fromthe same normalprobability distribution

• Issues– this model allows noise values

that could be greater thanmaximum camera output or lessthan zero

– for small standard deviations, thisisn’t too much of a problem - it’s afairly good model

– independence may not be justified(e.g. damage to lens)

– may not be stationary (e.g.thermal gradients in the ccd)For an image F,

the measured value G:

Gu,v = Fu,v + nu,v

n→DN(µ,σ 2) =

1

2πσ 2e−

1

2σ 2x−µ( )2

sigma=1

sigma=16

Finite differences and noise• Finite difference filters

respond strongly to noise– obvious reason: image noise

results in pixels that look verydifferent from theirneighbours

• Generally, the larger thenoise the stronger theresponse

• What is to be done?– intuitively, most pixels in

images look quite a lot liketheir neighbours

– this is true even at an edge;along the edge they’re similar,across the edge they’re not

– suggests that smoothing theimage should help, by forcingpixels different to theirneighbours (=noise pixels?)to look more like neighbours

Finite differences responding to noise

Increasing noise ->(this is zero mean additive gaussian noise)

The response of a linear filter to noise

• Do only stationary independent additive Gaussian noise withzero mean (non-zero mean is easily dealt with)

• Generalized Average (Mean):– output is a weighted sum of inputs

– so we want mean of a weighted sum of zero mean normal randomvariables

– must be zero

µ = wixii=1

N∑ wi =1

i=1

N∑

Ri, j = wi−u, j−vGu,vu,v∑ = wi−u, j−v Fu,v + nu,v( )u,v∑

Ri, j = wi−u, j−vFu,v + wi−u, j−vnu,vu,v∑u,v∑Ri, j = ˆ F u,v + µu,v

Gu,v = Fu,v + nu,vn→

DN(µ,σ 2)1

2πσ 2e−

1

2σ 2x−µ( )2

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

Response linear filter to noise

Var wi−u, j−vnu,vu,v∑

= E wi−u, j−v2 nu,v

2[ ]u,v∑

= wi−u, j−v2 E nu,v

2[ ]u,v∑= wi−u, j−v

2 σ 2u,v∑

=σ 2 wi−u, j−v2

u,v∑

• Variance:– recall

• variance of a sum of random variablesis sum of their variances

• variance of constant times randomvariable is constant^2 times variance

– then if σ is noise variance andkernel is w, variance of response is

Properties of sums of Gaussian random variables1N

ni = µi=1:N∑

Var 1N

nii=1:N∑

=

1N

E ni2[ ] =

i=1:N∑ 1

Nσ i

2

i=1:N∑

Filter responses are correlated

• over scales similar to the scale of the filter

• Filtered noise is sometimes useful– looks like some natural textures, can be used to simulate

fire, etc.

Smoothing reduces noise• Generally expect pixels to

“be like” their neighbours– surfaces turn slowly

– relatively few reflectancechanges

• Generally expect noiseprocesses to beindependent from pixel topixel

• Implies that smoothingsuppresses noise, forappropriate noise models

• Scale– the parameter in the

symmetric Gaussian– as this parameter goes up,

more pixels are involved inthe average

– and the image gets moreblurred

– and noise is more effectivelysuppressed

The effects of smoothing Each row shows smoothingwith gaussians of differentwidth; each column showsdifferent realisations of an image of gaussian noise.

Recommended