introduction to visual computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/lecture2.pdf ·...

60
Introduction to Visual Computing Prof. Feng Liu Winter 2020 http://www.cs.pdx.edu/~fliu/courses/cs410/ 01/09/2020

Upload: others

Post on 17-Jul-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Introduction to Visual Computing

Prof. Feng Liu

Winter 2020

http://www.cs.pdx.edu/~fliu/courses/cs410/

01/09/2020

Page 2: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Last Time

Course overview

◼ Admin. Info

◼ Computer Vision

Computer Vision at PSU

Image representation

Color

2

Page 3: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Today

Filter

3

Page 4: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Today

Filters and its applications

4

naïve denoising

Gaussian blur

better denoising

edge-preserving filter

Slide credit: Sylvain Paris and Frédo Durand

noisy image

Page 5: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Image filtering: compute function of local neighborhood at each pixel position

One type of “Local operator,” “Neighborhood operator,” “Window operator”

Useful for:◼ Enhancing images

Noise reduction, smooth, resize, increase contrast, etc.

◼ Extracting information from images

Texture, edges, distinctive points, etc.

◼ Detecting patterns

Template matching, e.g., eye template

Slide credit: C. Dyer and D. Hoiem

Image Filtering

Page 6: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

111

111

111

Slide credit: David Lowe

],[g

Example: Box Filter

Page 7: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Image Correlation Filtering

Center filter g at each pixel in image f

Multiply weights by corresponding pixels and

add them together

Set resulting value in output image h

g is called a filter, mask, kernel, or template

Linear filtering is sum of dot product at each

pixel position

Filtering operation called cross-correlation,

and denoted h = f g

Slide credit: C. Dyer

Page 8: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 0 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 0 0 0 0 0 0 0

0 0 90 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

0

0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 0 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 0 0 0 0 0 0 0

0 0 90 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

Credit: S. Seitz

],[],[],[,

lnkmflkgnmhlk

++=

[.,.]h[.,.]f

Image Filtering111

111

111

],[g

Page 9: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 0 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 0 0 0 0 0 0 0

0 0 90 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

0 10

0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 0 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 0 0 0 0 0 0 0

0 0 90 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

[.,.]h[.,.]f

Image Filtering111

111

111

],[g

],[],[],[,

lnkmflkgnmhlk

++=Credit: S. Seitz

Page 10: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 0 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 0 0 0 0 0 0 0

0 0 90 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

0 10 20

0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 0 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 0 0 0 0 0 0 0

0 0 90 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

[.,.]h[.,.]f

Image Filtering111

111

111

],[g

Credit: S. Seitz

],[],[],[,

lnkmflkgnmhlk

++=

Page 11: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 0 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 0 0 0 0 0 0 0

0 0 90 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

0 10 20 30

0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 0 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 0 0 0 0 0 0 0

0 0 90 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

[.,.]h[.,.]f

Image Filtering111

111

111

],[g

],[],[],[,

lnkmflkgnmhlk

++=Credit: S. Seitz

Page 12: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

0 10 20 30 30

0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 0 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 0 0 0 0 0 0 0

0 0 90 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

[.,.]h[.,.]f

Image Filtering111

111

111

],[g

],[],[],[,

lnkmflkgnmhlk

++=Credit: S. Seitz

Page 13: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

0 10 20 30 30

0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 0 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 0 0 0 0 0 0 0

0 0 90 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

[.,.]h[.,.]f

Image Filtering111

111

111

],[g

?

],[],[],[,

lnkmflkgnmhlk

++=Credit: S. Seitz

Page 14: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

0 10 20 30 30

50

0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 0 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 0 0 0 0 0 0 0

0 0 90 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

[.,.]h[.,.]f

Image Filtering111

111

111

],[g

?

],[],[],[,

lnkmflkgnmhlk

++=Credit: S. Seitz

Page 15: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 0 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 0 0 0 0 0 0 0

0 0 90 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

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 0 0 0 0

[.,.]h[.,.]f

Image Filtering 111

111

111],[g

],[],[],[,

lnkmflkgnmhlk

++=Credit: S. Seitz

Page 16: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

What does it do?

• Replaces each pixel with an average of its neighborhood

• Achieves smoothing effect (i.e., removes sharp features)

• Weaknesses:

• Blocky results

• Axis-aligned streaks

111

111

111

Slide credit: David Lowe

],[g

Box Filter

Page 17: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Smoothing with Box Filter

Slide credit: C. Dyer

Page 18: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Properties of Smoothing Filters

Smoothing

◼ Values all positive

◼ Sum to 1 constant regions same as input

◼ Amount of smoothing proportional to mask size

◼ Removes “high-frequency” components

◼ “low-pass” filter

Slide credit: C. Dyer

Page 19: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

000

010

000

Original

?

Source: D. Lowe

Practice with Linear Filters

Page 20: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

000

010

000

Original Filtered

(no change)

Source: D. Lowe

Practice with Linear Filters

Page 21: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

000

100

000

Original

?

Source: D. Lowe

Practice with Linear Filters

Page 22: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

000

100

000

Original Shifted left

by 1 pixel

Source: D. Lowe

Practice with Linear Filters

Page 23: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Original

111

111

111

000

020

000

- ?

(Note that filter sums to 1)

Source: D. Lowe

Practice with Linear Filters

Page 24: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Original

111

111

111

000

010

000

- ?

(Note that filter sums to 1)

Source: D. Lowe

Practice with Linear Filters

000

010

000

+

Page 25: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Original

111

111

111

000

020

000

-

Sharpening filter- Sharpen an out of focus image by subtracting a multiple of a blurred version

Source: D. Lowe

Practice with Linear Filters

Page 26: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Source: D. Lowe

Sharpening

Page 27: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

h = f + k(f * g) where k is a small positive constant and g =

Called unsharp masking in photography

0 1 0

1 -4 1

0 1 0

called a Laplacian mask

Sharpening by Unsharp Masking

Page 28: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Sharpening using Unsharp Mask Filter

Original Filtered result

Slide credit: C. Dyer

Page 29: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

-101

-202

-101

Vertical Edge(absolute value)

Sobel

Other Filters: Edge Detection

Slide credit: C. Dyer

Page 30: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

-1-2-1

000

121

Horizontal Edge(absolute value)

Sobel

Other Filters: Edge Detection

Slide credit: C. Dyer

Page 31: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Linearity:

filter(f1 + f2) = filter(f1) + filter(f2)

Shift invariance: same behavior regardless of pixel

location

filter(shift(f)) = shift(filter(f))

Source: S. Lazebnik

Key Properties of Linear Filters

Page 32: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Weight contributions of neighboring pixels by nearness

Constant factor at front makes volume sum to 1

Convolve each row of image with 1D kernel to produce new

image; then convolve each column of new image with same 1D

kernel to yield output image

0.003 0.013 0.022 0.013 0.0030.013 0.059 0.097 0.059 0.0130.022 0.097 0.159 0.097 0.0220.013 0.059 0.097 0.059 0.0130.003 0.013 0.022 0.013 0.003

5 x 5, = 1

Slide credit: Christopher Rasmussen

Gaussian Filtering

Page 33: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Smoothing with a box

actually doesn’t compare at

all well with a defocused lens

Most obvious difference is

that a single point of light

viewed in a defocused lens

looks like a fuzzy blob; but

the averaging process would

give a little square

Gaussian is isotropic (i.e.,

rotationally symmetric) A Gaussian gives a good

model of a fuzzy blob

It closely models many

physical processes (the sum

of many small effects)

Slide by D.A. Forsyth

Smoothing with a Gaussian

Page 34: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

What does Blurring take away?

originalSlide credit: C. Dyer

Page 35: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

What does Blurring take away?

smoothed (5x5 Gaussian)Slide credit: C. Dyer

Page 36: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Smoothing with Gaussian Filter

Page 37: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Smoothing with Box Filter

Page 38: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

input

Slide by S. Paris

Page 39: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

box average

Slide by S. Paris

Page 40: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Gaussian blur

Slide by S. Paris

Page 41: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

What parameters matter here?

Standard deviation, , of Gaussian: determines extent

of smoothing

σ = 2 with 30 x 30 kernel

σ = 5 with 30 x 30 kernel

Source: D. Hoiem

Gaussian Filters

Page 42: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Slide credit: C. Dyer

Page 43: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Parameter σ is the “scale” / “width” / “spread” of the Gaussian kernel, and controls the amount of smoothing

Smoothing with a Gaussian

Slide credit: C. Dyer

Page 44: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Slide by D.A. Forsyth

Small

Page 45: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Slide by D.A. Forsyth

Medium

Page 46: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Slide by D.A. Forsyth

Large

Page 47: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Gaussian filters

= 30 pixels= 1 pixel = 5 pixels = 10 pixels

Slide credit: C. Dyer

Page 48: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Source: K. Grauman

* =

Cascading Gaussian Filters

Remove “high-frequency” components from the image

(low-pass filter)

◼ Images become smoother / more blurred

Convolution with self is another Gaussian

◼ Convolving two times with Gaussian kernel of width σ is

same as convolving once with kernel of width σ√2

Page 49: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

A function g(x, y) is separable if g(x, y) = g1(x) g2(y)

The Gaussian function is separable:

e -[(x2 + y2)/22] = e -[x

2/22]* e -[y

2/22]

First convolve the image with a 1D horizontal filter

Then convolve the result of the first convolution with a 1D vertical filter

For a k x k Gaussian filter, 2D convolution requires k2 multiplications and k2-1 additions per pixel

But using the separable filters, we reduce this to 2kmultiplications and 2k-1 additions per pixel

Separability

Slide credit: C. Dyer

Page 50: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Separability

2 3 3

3 5 5

4 4 6

1 2 1

1

2

1

18

11

18

18

11

18

65

1 2 11

2

1

1 2 1

2 4 2

1 2 1

2 3 3

3 5 5

4 4 6

= 2 + 6 + 3 = 11

= 6 + 20 + 10 = 36

= 4 + 8 + 6 = 18

65

=

x

g1 =

g2 =

f =

Slide credit: C. Dyer

Page 51: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

What parameters matter here?

Size of kernel or mask

σ = 5 with 10 x 10 kernel

σ = 5 with 30 x 30 kernel

Gaussian Filters

Slide credit: C. Dyer

Page 52: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Gaussian function has infinite “support” but need a finite-size kernel

Values at edges should be near 0

98.8% of area under Gaussian in mask of size 5σ x 5σ

In practice, use mask of size 2k+1 x 2k+1 where k 3

Normalize output by dividing by sum of all weights

How big should the filter be?

Slide credit: C. Dyer

Page 53: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

What about near the edge?

◼ the filter window falls off the edge of the image

◼ need to extrapolate

◼ methods:

clip filter (black)

wrap around

copy edge

reflect across edge

Source: S. Marschner

Practical Matters

Page 54: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Filter Re-cap

56

naïve denoising

Gaussian blur

better denoising

edge-preserving filter

Slide credit: Sylvain Paris and Frédo Durand

noisy image

Page 55: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Median Filter

• Replace pixel by the

median value of its

neighbors

• No new pixel values

introduced

• Removes spikes: good

for impulse, salt &

pepper noise

• Nonlinear filter

Slide credit: C. Dyer

Page 56: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Salt and pepper noise

Median filtered

Plots of a row of the image

Median Filter

Slide credit: M. Hebert, C. Dyer

Page 57: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Median filter is edge preserving

Median Filter

Slide credit: C. Dyer

Page 58: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Slide credit: C. Dyer

Page 59: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Median Filter (19 x 19 window)

input outputimages by J. PlushSlide credit: C. Dyer

Page 60: Introduction to Visual Computingweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture2.pdf · 2020-01-10 · Computer Vision Computer Vision at PSU Image representation Color 2. Today

Next Time

More filters

Feature detection

62