Image Processing I Computer Vision Fall 2018 Columbia University - - PowerPoint PPT Presentation

image processing i
SMART_READER_LITE
LIVE PREVIEW

Image Processing I Computer Vision Fall 2018 Columbia University - - PowerPoint PPT Presentation

Image Processing I Computer Vision Fall 2018 Columbia University Homework 1 Posted online today Due September 24 before class starts Turn in PDF and your code online Office Hours Carl: Monday 4:30pm to 5:30pm, CSB 502 Oscar:


slide-1
SLIDE 1

Image Processing I

Computer Vision Fall 2018 Columbia University

slide-2
SLIDE 2

Homework 1

  • Posted online today
  • Due September 24 before class starts
  • Turn in PDF and your code online
slide-3
SLIDE 3

Office Hours

  • Carl: Monday 4:30pm to 5:30pm, CSB 502
  • Oscar: Thursday 3-4pm, Mudd 500
  • Xiaoning: Monday, 5-6pm, CS TA Room
  • Bo: Tuesday, 3-4pm, CS TA Room
  • James: Thursday 12-1pm, CS TA Room
  • Luc: Tuesday 4-5pm, CS TA Room
slide-4
SLIDE 4

Image Formation

Slide credit: Steve Seitz

Object Film

slide-5
SLIDE 5

Image Formation

Add a barrier to block off most of the rays

Slide credit: Steve Seitz

Object Film Barrier

slide-6
SLIDE 6

Image denoising

Slide credit: S. Lazebnik

slide-7
SLIDE 7

Average many photos!

Slide credit: S. Lazebnik

Time

slide-8
SLIDE 8

What if just one?

Slide credit: S. Lazebnik

slide-9
SLIDE 9

Reminder: Images as Functions

F[x, y]

slide-10
SLIDE 10

Moving Average

90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90

Source: S. Seitz

F[x, y]

slide-11
SLIDE 11

Moving Average

90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90

Source: S. Seitz

F[x, y]

slide-12
SLIDE 12

Moving Average

90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 10

Source: S. Seitz

F[x, y]

slide-13
SLIDE 13

Moving Average

90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 10 20

Source: S. Seitz

F[x, y]

slide-14
SLIDE 14

Moving Average

90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 10 20 30

Source: S. Seitz

F[x, y]

slide-15
SLIDE 15

Moving Average

90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 10 20 30

Source: S. Seitz

F[x, y]

?

slide-16
SLIDE 16

Moving Average

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

Source: S. Seitz

F[x, y]

slide-17
SLIDE 17

Filtering

We want to remove unwanted sources of variation, and keep the information relevant for whatever task we need to solve

Source: Bill Freeman

Input Image Output Image Filter

slide-18
SLIDE 18

Linear Filtering

Source: Bill Freeman

For a filter to be linear, it must satisfy two properties:

  • filter(im, f1 + f2) = filter(im, f1) + filter(im, f2)
  • C * filter(im, f1) = filter(im, C * f1)

Input Image Output Image Filter

slide-19
SLIDE 19

Convolution

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

* =

1 9

F[x, y]

G[x, y]

slide-20
SLIDE 20
  • Let f be an image/function, and g is the kernel/filter
  • The convolution is defined as:

Convolution

(f * g)[x, y] = ∑

i,j

f[x − i, y − j]g[i, j]

slide-21
SLIDE 21

Convolution

(f * g)[x, y] = ∑

i,j

f[x − i, y − j]g[i, j]

f g

slide-22
SLIDE 22

Convolution

(f * g)[x, y] = ∑

i,j

f[x − i, y − j]g[i, j]

f g

Flip LR, UD

slide-23
SLIDE 23

Convolution Practice

1

Source: D. Lowe

?

slide-24
SLIDE 24

1

Source: D. Lowe

Convolution Practice

slide-25
SLIDE 25

1

Source: D. Lowe

?

Convolution Practice

slide-26
SLIDE 26

1

Source: D. Lowe

Translation Filter

Convolution Practice

slide-27
SLIDE 27

1 1 1 1 1 1 1 1 1

Source: D. Lowe

1 9

?

Convolution Practice

slide-28
SLIDE 28

1 1 1 1 1 1 1 1 1

Source: D. Lowe

1 9

Blur Filter

Convolution Practice

slide-29
SLIDE 29

Source: D. Lowe

Convolution Practice

?

slide-30
SLIDE 30

1 1 1 1 1 1 1 1 1

Source: D. Lowe

− 1 9

2

?

Convolution Practice

slide-31
SLIDE 31

1 1 1 1 1 1 1 1 1

Source: D. Lowe

− 1 9

2

Sharpening Filter

Convolution Practice

slide-32
SLIDE 32

Sharpening

Source: D. Lowe

slide-33
SLIDE 33

Sharpening

Image Blurred Detail Image Detail Sharpened

  • =

+ =

slide-34
SLIDE 34

Convolution Properties

F ∗ H = H ∗ F (F ∗ H) ∗ G = F ∗ (H ∗ G) (F ∗ G) + (H ∗ G) = (F + H) ∗ G

Commutative: Associative: Distributive:

slide-35
SLIDE 35

Convolution Properties

Shift Invariance: Scale: filter(shift(f)) = shift(filter(f)) filter(A * f) = A * filter(f)

slide-36
SLIDE 36

Cross-Correlation

(f * g)[x, y] = ∑

i,j

f[x + i, y + j]g[i, j]

  • Conceptually simpler, but not as nice properties:

f g

slide-37
SLIDE 37

Boundary Issues

f g g g g f g g g g f g g g g

full same valid

Slide credit: S. Lazebnik

slide-38
SLIDE 38

Border Padding

Circular Replicate Symmetric Zero Pad

slide-39
SLIDE 39

Box Filter

slide-40
SLIDE 40

Gaussian Filter

slide-41
SLIDE 41

Gaussian Filter

0.003 0.013 0.022 0.013 0.003 0.013 0.059 0.097 0.059 0.013 0.022 0.097 0.159 0.097 0.022 0.013 0.059 0.097 0.059 0.013 0.003 0.013 0.022 0.013 0.003

5 x 5, σ = 1

Source: C. Rasmussen

Constant factor at front makes volume sum to unity

slide-42
SLIDE 42

Standard Deviation

Source: K Grauman

σ = 2 with 30 x 30 kernel σ = 5 with 30 x 30 kernel Standard deviation σ: determines extent of smoothing

slide-43
SLIDE 43

Changing Sigma

slide-44
SLIDE 44

Kernel Width

Source: K Grauman

The Gaussian function has infinite support, but discrete filters use finite kernels Rule of thumb: set filter half-width to about 3σ

slide-45
SLIDE 45

Complexity

What is the complexity of filtering an n×n image with an m×m kernel?

slide-46
SLIDE 46

Complexity

What is the complexity of filtering an n×n image with an m×m kernel? O(n2 m2)

slide-47
SLIDE 47

Separable Convolution

G(x, y) = 1 2πσ2 exp (− x2 + y2 2σ2 ) = 1 2πσ exp (− x2 2σ2) 1 2πσ exp (− y2 2σ2 )

Two dimensional Gaussian is product of two Gaussians:

f = f * * *

Take advantage of associativity:

slide-48
SLIDE 48

Complexity

What is the complexity of filtering an n×n image with an m×m kernel? O(n2 m2) What if kernel is separable?

slide-49
SLIDE 49

Complexity

What is the complexity of filtering an n×n image with an m×m kernel? O(n2 m2) What if kernel is separable? O(n2 m)

slide-50
SLIDE 50

Denoising

Additive Gaussian Noise Gaussian Filter (sigma=1)

slide-51
SLIDE 51

What’s wrong?

Salt and Pepper Noise Gaussian Filter (sigma=1)

slide-52
SLIDE 52

Median Filter

  • A median filter operates over a window by selecting the

median intensity in the window
 
 
 
 
 
 


Is median filtering linear?

Source: Kristen Grauman

slide-53
SLIDE 53

Why use median?

Source: Kristen Grauman

slide-54
SLIDE 54

What’s wrong?

Salt and Pepper Noise Median Filter 3x3

slide-55
SLIDE 55

Median Filtering

Median 3x3 Median 5x5 Median 9x9

slide-56
SLIDE 56

Image Gradients

slide-57
SLIDE 57

Image Gradients

How does intensity change as you move left to right? How do you take the derivative of an image?

slide-58
SLIDE 58

First Derivative

* [−1,1] = * [−1,1]T =

∂I ∂x ∂I ∂y

slide-59
SLIDE 59

Second Derivative

* [−1,1] = * [−1,1]T =

∂2I ∂x2 ∂2I ∂y2

slide-60
SLIDE 60

Image Gradients

Source: Seitz and Szeliski

slide-61
SLIDE 61

What causes an edge?

Source: G Hager

slide-62
SLIDE 62

What causes an edge?

Source: G Hager

Surface normal discontinuities

slide-63
SLIDE 63

What causes an edge?

Source: G Hager

Boundaries of material properties

slide-64
SLIDE 64

What causes an edge?

Source: G Hager

Boundaries of material properties

slide-65
SLIDE 65

What causes an edge?

Source: G Hager

Boundaries of lighting

slide-66
SLIDE 66

Edge Types

Source: G Hager

slide-67
SLIDE 67

What is an edge?

Source: G Hager

slide-68
SLIDE 68

What about noise?

Source: G Hager

slide-69
SLIDE 69

Handling Noise

  • Filter with a Gaussian to smooth, then take gradients
  • But, convolution is linear

* [−1,1]T * [−1,1]T = * [−1,1] * [−1,1] =

Gaussian Filter Laplacian Filter

slide-70
SLIDE 70

The Laplacian Filter

  • Popularized by Marr and Hildreth in 1980 to locate

boundaries between objects

  • Defined as the sum of second order partial derivatives:

∇I = ∂2I ∂x2 + ∂2I ∂y2

slide-71
SLIDE 71

Aside: Gabor Filters

Cosine wave multiple by a Gaussian

Source: MathWorks

ψ(x, y) = e− x2 + y2

2σ2 cos(2πμx)

slide-72
SLIDE 72

Aside: Human Visual System

slide-73
SLIDE 73

Aside: Cat Visual System

Source: Antonio Torralba

slide-74
SLIDE 74

Detection

slide-75
SLIDE 75

Finding Boundaries

f g

∂2f ∂x2 + ∂2f ∂y2 > λ

slide-76
SLIDE 76

Finding Things

Source: James Hays, Deva Ramanan

f * g f g

slide-77
SLIDE 77

Source: James Hays, Deva Ramanan

f g

fij g

θij

fT

ij g = ∥fij∥∥g∥ cos θij

Response for one window:

fij

Detection by Filtering

slide-78
SLIDE 78

Source: James Hays, Deva Ramanan

f * (g − ¯ g) f g

True detections False detections

Find the filter

Detection by Filtering

Filter Response Thresholded

slide-79
SLIDE 79

Source: James Hays, Deva Ramanan

True detections

Sum of Squared Differences

1-sqrt(SSD) Thresholded

SSD[i, j] = ∥fij − h∥2

2

= (fij − h)

T

(fij − h)

How do you write this as a linear filter?

slide-80
SLIDE 80

Source: Deva Ramanan

Sum of Squared Differences

What does SSD do here? 1-sqrt(SSD)

slide-81
SLIDE 81

Normalized Cross Correlation

NCC[i, j] = fT

ijh

∥fij∥∥h∥ = cos θij

Source: Deva Ramanan

slide-82
SLIDE 82

Intra-class variance

slide-83
SLIDE 83

Convolutional Networks

Convolution is building blocks for modern object recognition systems LeNet5

slide-84
SLIDE 84

Pyramids

slide-85
SLIDE 85

Scale

slide-86
SLIDE 86

Image Pyramids

Image: Wikipedia

  • Recursively resize image by

a factor of two

  • Called pyramid because it

looks like a pyramid

  • Invariance to scale by

running operation over each level of the pyramid

slide-87
SLIDE 87

How to resize images?

Skip every

  • ther pixel

Why does this look bad?

slide-88
SLIDE 88

Aliasing

Source: Efros

slide-89
SLIDE 89

Aliasing

Source: Efros

slide-90
SLIDE 90
slide-91
SLIDE 91

Gaussian Pyramids

  • 1. Convolve with Gaussian filter
  • 2. Subsample every other pixel
  • 3. Repeat
slide-92
SLIDE 92

Laplacian Pyramids

  • 1. Convolve with Laplacian filter
  • 2. Subsample every other pixel
  • 3. Repeat

Store downsampled image, not gradients

slide-93
SLIDE 93

Recovering Image

Upsample Add Level L Image L-1 Image L

slide-94
SLIDE 94

Laplacian Pyramids

  • Compression
  • Incremental transmission

Applications:

slide-95
SLIDE 95

Image Blending

slide-96
SLIDE 96

Image Blending

slide-97
SLIDE 97

Image Blending

Image A Image B Region R

slide-98
SLIDE 98

Image Blending

slide-99
SLIDE 99

Next Class: Repetition