Top Banner
Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest. Useful to: Integrate information over constant regions. – Scale. Detect changes. Fourier analysis. Many nice slides taken from Bill Freeman.
41

Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

Dec 22, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

Linear Filtering

• About modifying pixels based on neighborhood. Local methods simplest.

• Linear means linear combination of neighbors. Linear methods simplest.

• Useful to:– Integrate information over constant regions.– Scale.– Detect changes.

• Fourier analysis.• Many nice slides taken from Bill Freeman.

Page 2: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

(Freeman)

Page 3: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

(Freeman)

Page 4: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

Correlation

Examples on white board – 1D

Examples -2D

Page 5: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

For example, let’s take a vector like:

(1 2 3 2 3 2 1), and filter it with a filter like (1/3 1/3 1/3)

Ignoring the ends for the moment, we get a result like:

2 2 1/3 2 2/3 2 1/3 2. We can also graph the results and see that the original vector is smoothed out.

Page 6: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

Boundaries

• Zeros

• Repeat values

• Cycle

• Produce shorter result

• Examples

Page 7: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

Correlation

N

Ni

ixIiFxIF )()()(

N

Nj

N

Ni

jyixIjiFyxIF ),(),(),(

For this notation, we index F from –N to N.

Page 8: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

Convolution

• Like Correlation with Filter Reversed• Associative

N

Ni

ixIiFxIF )()()(

N

Nj

N

Ni

jyixIjiFyxIF ),(),(),(

1D

2D

Page 9: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

Some Examples

Page 10: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.
Page 11: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.
Page 12: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.
Page 13: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.
Page 14: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.
Page 15: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.
Page 16: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.
Page 17: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.
Page 18: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.
Page 19: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.
Page 20: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.
Page 21: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.
Page 22: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.
Page 23: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.
Page 24: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

Filtering to reduce noise

• Noise is what we’re not interested in.– We’ll discuss simple, low-level noise today:

Light fluctuations; Sensor noise; Quantization effects; Finite precision

– Not complex: shadows; extraneous objects.

• A pixel’s neighborhood contains information about its intensity.

• Averaging noise reduces its effect.

Page 25: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

Additive noise

• I = S + N. Noise doesn’t depend on signal.

• We’ll consider:

ddistributey identicall ,

for t independen ,

tic.determinis

0)( with

ji

jiji

i

iiii

nn

nnnn

s

nEnsI

Page 26: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

Average Filter• Mask with positive

entries, that sum 1.• Replaces each pixel

with an average of its neighborhood.

• If all weights are equal, it is called a BOX filter.

11

1111

11

11 111111

11

FF

1/91/9

(Camps)

Page 27: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

Averaging Filter and noise reduction

• Example: try executing:k=1; figure(1); hist(sum((1/k)*rand(k,1000)))

for different values of k.• The average of noise is smaller than one example.

– This is intuitive– Can be proven in many cases (some technical conditions:

noise must be independent, many samples….)– Actually true for many real examples: Gaussian noise,

flipping a coin many times

Page 28: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

Filtering reduces noise if signal stable

• Suppose I(i) = I+n(i), I(i+1) = I+n(i+1) I(i+2) = I+n(i+2).

• Average of I(i), I(i+1), I(i+2) = I + average of n(i), n(i+1), n(i+2).

• When there is no noise, averaging smooths the signal.

• So in real life, averaging does both.

Page 29: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

Example: Smoothing by Averaging

Page 30: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

Smoothing as Inference About the Signal

+ =

Nearby points tell more about the signal than distant ones.

Neighborhood for averaging.

Page 31: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

Gaussian Averaging

• Rotationally symmetric.

• Weights nearby pixels more than distant ones.– This makes sense

as probabalistic inference.

• A Gaussian gives a good model of a fuzzy blob

Page 32: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

An Isotropic Gaussian

• The picture shows a smoothing kernel proportional to

(which is a reasonable model of a circularly symmetric fuzzy blob)

2

22

0 2exp

2

1),(

yxyxG

Page 33: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

Smoothing with a Gaussian

Page 34: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

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

Page 35: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

Efficient Implementation

• Both, the BOX filter and the Gaussian filter are separable:– First convolve each row with a 1D filter– Then convolve each column with a 1D

filter.

Page 36: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

Box Filter

0003

1

3

1

3

1000

03

10

03

10

03

10

9

1

9

1

9

19

1

9

1

9

19

1

9

1

9

1

Page 37: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

Gaussian Filter

2

2

2

2

2

22

0 2exp

2exp

2

12

exp2

1),(

yxyxyxG

Page 38: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

Smoothing as Inference About the Signal: Non-linear Filters.

+ =

What’s the best neighborhood for inference?

Page 39: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

Filtering to reduce noise: Lessons

• Noise reduction is probabilistic inference.

• Depends on knowledge of signal and noise.

• In practice, simplicity and efficiency important.

Page 40: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

Filtering and Signal

• Smoothing also smooths signal.• Matlab• Removes detail• Matlab• This is good and bad: - Bad: can’t remove noise w/out blurring

shape. - Good: captures large scale structure;

allows subsampling.

Page 41: Linear Filtering About modifying pixels based on neighborhood. Local methods simplest. Linear means linear combination of neighbors. Linear methods simplest.

Subsampling

Matlab