Lecture 4: Linear filters Tuesday, Sept 11 Many slides by (or - - PDF document

lecture 4 linear filters
SMART_READER_LITE
LIVE PREVIEW

Lecture 4: Linear filters Tuesday, Sept 11 Many slides by (or - - PDF document

Lecture 4: Linear filters Tuesday, Sept 11 Many slides by (or adapted from) D. Forsyth, Y. Boykov, L. Davis, W. Freeman, M. Hebert, D. Kreigman, P. Duygulu Image neighborhoods Q: What happens if we reshuffle all pixels within the image?


slide-1
SLIDE 1

Lecture 4: Linear filters

Tuesday, Sept 11

Many slides by (or adapted from) D. Forsyth, Y. Boykov, L. Davis, W. Freeman, M. Hebert, D. Kreigman, P. Duygulu

slide-2
SLIDE 2

Image neighborhoods

  • Q: What happens if we reshuffle all pixels within the

image?

  • A: Its histogram won’t change.

Point-wise processing unaffected.

  • Filters reflect spatial information
slide-3
SLIDE 3

Image filtering

Modify the pixels in an image based on some function of a local neighborhood of the pixels 10 5 3 4 5 1 1 1 7

7

Some function

slide-4
SLIDE 4

Linear filtering

  • Replace each pixel with a linear combination of

its neighbors.

  • Convolution kernel: prescription for the linear

combination

10 5 3 4 5 1 1 1 7

7

*

0.5 1.0 0.5 =

kernel

slide-5
SLIDE 5

Why filter images?

  • Noise reduction
  • Image enhancement
  • Feature extraction
slide-6
SLIDE 6

Convolution

signal kernel

slide-7
SLIDE 7

Convolution

Shapiro & Stockman

slide-8
SLIDE 8

Convolution example

slide-9
SLIDE 9

Convolution example

slide-10
SLIDE 10

(in both dims)

slide-11
SLIDE 11

Filtering examples

slide-12
SLIDE 12

Filtering examples: Identity

slide-13
SLIDE 13

Filtering examples

slide-14
SLIDE 14

Filtering examples: Blur

slide-15
SLIDE 15

Filtering examples: Blur

slide-16
SLIDE 16

Filtering examples: Blur

slide-17
SLIDE 17

Filtering examples

slide-18
SLIDE 18

Filtering examples: Shift

slide-19
SLIDE 19

Filtering examples

slide-20
SLIDE 20

Filtering examples: sharpening

slide-21
SLIDE 21

Filtering examples: sharpening

slide-22
SLIDE 22

Properties

  • Shift invariant

– G(Shift(f(x))=Shift(G(f(x)))

  • Linear

– G(k f(x))=kG(f(x)) – G(f+g) = G(f) + G(g)

slide-23
SLIDE 23

Properties

  • Associative: (f * g) * h = f * (g * h)
  • Differentiation rule:
slide-24
SLIDE 24

Filters as templates

  • Applying filter = taking a

dot-product between image and some vector

  • Filtering the image is a

set of dot products

  • Insight

– filters look like the effects they are intended to find – filters find effects they look like

slide-25
SLIDE 25

The University of Ontario

Original Gaussian noise Salt and pepper noise Impulse noise

Noise

Common types of noise:

  • Salt and pepper noise:

random occurrences of black and white pixels

  • Impulse noise: random
  • ccurrences of white pixels
  • Gaussian noise:

variations in intensity drawn from a Gaussian normal distribution

Filtering is useful for noise reduction...

slide-26
SLIDE 26

Gaussian noise

slide-27
SLIDE 27

Effect of sigma on Gaussian noise

slide-28
SLIDE 28

Effect of sigma on Gaussian noise

slide-29
SLIDE 29

Effect of sigma on Gaussian noise

slide-30
SLIDE 30

sigma=1 Effect of sigma on Gaussian noise

slide-31
SLIDE 31

sigma=16 Effect of sigma on Gaussian noise

slide-32
SLIDE 32

Gaussian noise

  • Issues

– allows noise values greater than maximum or less than zero – good model for small standard deviations – independence may not be justified – does not model other sources of “noise”

slide-33
SLIDE 33

Smoothing and noise

  • Expect pixels to “be like” their neighbors
  • Expect noise processes to be independent from

pixel to pixel

  • Smoothing suppresses noise, for appropriate

noise models

  • Impact of scale: more pixels involved in the

image, more noise suppressed, but also more blurring

slide-34
SLIDE 34

Mean filtering

0 90 90 90 90 90 0 0 90 90 90 90 90 0 0 90 90 90 90 90 0 0 90 0 90 90 90 0 0 90 90 90 90 90 0 0 90 0

slide-35
SLIDE 35

0 90 90 90 90 90 0 0 90 90 90 90 90 0 0 90 90 90 90 90 0 0 90 0 90 90 90 0 0 90 90 90 90 90 0 0 90 0

Mean filtering

0 10 20 30 30 30 20 10 0 20 40 60 60 60 40 20 0 30 60 90 90 90 60 30 0 30 50 80 80 90 60 30 0 30 50 80 80 90 60 30 0 20 30 50 50 60 40 20 10 20 30 30 30 30 20 10 10 10 10 0

slide-36
SLIDE 36

Effect of mean filters

Gaussian noise Salt and pepper noise 3x3 5x5 7x7

slide-37
SLIDE 37

Mean kernel

  • What’s the kernel for a 3x3 mean filter?

0 90 90 90 90 90 0 0 90 90 90 90 90 0 0 90 90 90 90 90 0 0 90 0 90 90 90 0 0 90 90 90 90 90 0 0 90 0

] , [ y x F ] , [ v u H

slide-38
SLIDE 38

Smoothing by Averaging

slide-39
SLIDE 39

Smoothing with a Gaussian

  • Averaging does not model

defocused lens well

  • Gaussian kernel weights

pixels at its center much more strongly than its boundaries

slide-40
SLIDE 40

Isotropic Gaussian

Reasonable model of a circularly symmetric blob

slide-41
SLIDE 41

Smoothing with a Gaussian

slide-42
SLIDE 42
slide-43
SLIDE 43

Gaussian filters

  • Gaussian function has infinite support, but

discrete filters use finite kernels

1 2 1 2 4 2 1 2 1

] , [ v u H

⋅ 16 1

slide-44
SLIDE 44

Gaussian filters

slide-45
SLIDE 45

More noise - Wider kernel

Smoothing and noise

slide-46
SLIDE 46

Gaussian filters

  • Remove “high-frequency” components

from the image “low pass” filter

  • Convolution with self is another Gaussian

– So can smooth with small-width kernel, repeat, and get same result as larger-width kernel would have – 2x with σ 1x with √2σ

  • Separable kernel
slide-47
SLIDE 47

Separability

  • Isotropic Gaussians factorable into product
  • f two 1D Gaussians
  • Useful: can convolve all rows, then all

columns

  • Linear vs. quadratic time in mask size
slide-48
SLIDE 48

Separability

slide-49
SLIDE 49

Correlation of filter responses

  • Filter responses are correlated over scales

similar to scale of filter

  • Filtered noise is sometimes useful

– looks like some natural textures

slide-50
SLIDE 50
slide-51
SLIDE 51
slide-52
SLIDE 52
slide-53
SLIDE 53

Edges and derivatives

  • Edges correspond to fast changes
slide-54
SLIDE 54

Edges and derivatives

slide-55
SLIDE 55

Finite difference filters

1

  • 1

] , [ v u H

Image derivatives can be approximated with convolution.

slide-56
SLIDE 56

Finite differences

  • M = [-1 0 1]
slide-57
SLIDE 57

Finite difference filters

slide-58
SLIDE 58

Finite differences

Which is derivative in the x direction?

slide-59
SLIDE 59

Finite differences

Increasing noise -> (zero mean additive Gaussian noise)

Strong response to fast change sensitive to noise

slide-60
SLIDE 60

Smoothed derivatives

  • Smooth before differentiation: assume that

“meaningful” changes won’t be suppressed by smoothing, but noise will

  • Two convolutions: smooth, then

differentiate?

slide-61
SLIDE 61

Smoothed derivatives

slide-62
SLIDE 62

Derivative of Gaussian filter

[ ]

1 1 − ⊗

[ ]

0.0030 0.0133 0.0219 0.0133 0.0030 0.0133 0.0596 0.0983 0.0596 0.0133 0.0219 0.0983 0.1621 0.0983 0.0219 0.0133 0.0596 0.0983 0.0596 0.0133 0.0030 0.0133 0.0219 0.0133 0.0030

) ( ) ( h g I h g I ⊗ ⊗ = ⊗ ⊗

slide-63
SLIDE 63

Derivative of Gaussian filter

σ = 1 pixel σ = 3 pixels σ = 7 pixels

Derivatives in the x direction

slide-64
SLIDE 64

Derivative of Gaussian filter

The apparent structures differ depending on Gaussian’s scale parameter.

σ = 1 pixel σ = 2 pixels

slide-65
SLIDE 65

Smoothed derivatives: caveat

  • Tradeoff between localization and smoothing
slide-66
SLIDE 66
slide-67
SLIDE 67

Typical mask properties

  • Derivatives

– Opposite signs used to get high response in regions of high contrast – Sum to 0 no response in constant regions – High absolute value at points of high contrast

  • Smoothing

– Values positive – Sum to 1 constant regions same as input – Amount of smoothing proportional to mask size

slide-68
SLIDE 68

Median filter

  • Non-linear
  • No new pixel values
  • Removes spikes
slide-69
SLIDE 69

Median filter

Salt and pepper noise Median filtered

slide-70
SLIDE 70

Median filter

slide-71
SLIDE 71

Median filter

slide-72
SLIDE 72

Next

  • More on edges, pyramids, and texture
  • Pset 1 out tomorrow
  • Reading: chapters 8 and 9