Image Pyramids Sanja Fidler CSC420: Intro to Image Understanding 1 - - PowerPoint PPT Presentation

image pyramids
SMART_READER_LITE
LIVE PREVIEW

Image Pyramids Sanja Fidler CSC420: Intro to Image Understanding 1 - - PowerPoint PPT Presentation

Image Pyramids Sanja Fidler CSC420: Intro to Image Understanding 1 / 35 Finding Waldo Lets revisit the problem of finding Waldo This time he is on the road template (filter) image Sanja Fidler CSC420: Intro to Image Understanding 2 /


slide-1
SLIDE 1

Image Pyramids

Sanja Fidler CSC420: Intro to Image Understanding 1 / 35

slide-2
SLIDE 2

Finding Waldo

Let’s revisit the problem of finding Waldo This time he is on the road image template (filter)

Sanja Fidler CSC420: Intro to Image Understanding 2 / 35

slide-3
SLIDE 3

Finding Waldo

He comes closer but our filter doesn’t know that How can we find Waldo? image template (filter)

Sanja Fidler CSC420: Intro to Image Understanding 3 / 35

slide-4
SLIDE 4

Idea: Re-size Image

Re-scale the image multiple times! Do correlation on every size! template (filter)

Sanja Fidler CSC420: Intro to Image Understanding 4 / 35

slide-5
SLIDE 5

Sanja Fidler CSC420: Intro to Image Understanding 5 / 35

slide-6
SLIDE 6

This image is huge. How can we make it smaller?

Sanja Fidler CSC420: Intro to Image Understanding 5 / 35

slide-7
SLIDE 7

Image Sub-Sampling

Idea: Throw away every other row and column to create a 1/2 size image

1/4 1/8

[Source: S. Seitz]

Sanja Fidler CSC420: Intro to Image Understanding 6 / 35

slide-8
SLIDE 8

Image Sub-Sampling

Why does this look so crufty?

!"#$$%&'$())*+$ !",$$%#'$())*+$ !"&$

[Source: S. Seitz]

Sanja Fidler CSC420: Intro to Image Understanding 7 / 35

slide-9
SLIDE 9

Even worse for synthetic images

I want to resize my image by factor 2 And I take every other column and every other row (1st, 3rd, 5th, etc) Figure: Dashed line denotes the border of the image (it’s not part of the image)

Sanja Fidler CSC420: Intro to Image Understanding 8 / 35

slide-10
SLIDE 10

Even worse for synthetic images

I want to resize my image by factor 2 And I take every other column and every other row (1st, 3rd, 5th, etc) Where is the rectangle! Figure: Dashed line denotes the border of the image (it’s not part of the image)

Sanja Fidler CSC420: Intro to Image Understanding 8 / 35

slide-11
SLIDE 11

Even worse for synthetic images

What’s in the image? Now I want to resize my image by half in the width direction And I take every other column (1st, 3rd, 5th, etc)

Sanja Fidler CSC420: Intro to Image Understanding 9 / 35

slide-12
SLIDE 12

Even worse for synthetic images

What’s in the image? Now I want to resize my image by half in the width direction And I take every other column (1st, 3rd, 5th, etc)

Sanja Fidler CSC420: Intro to Image Understanding 9 / 35

slide-13
SLIDE 13

Even worse for synthetic images

What’s in the image? Now I want to resize my image by half in the width direction And I take every other column (1st, 3rd, 5th, etc) Where is the chicken!

Sanja Fidler CSC420: Intro to Image Understanding 9 / 35

slide-14
SLIDE 14

Image Sub-Sampling

[Source: F. Durand]

Sanja Fidler CSC420: Intro to Image Understanding 10 / 35

slide-15
SLIDE 15

Even worse for synthetic images

What’s happening? [Source: L. Zhang]

Sanja Fidler CSC420: Intro to Image Understanding 11 / 35

slide-16
SLIDE 16

Aliasing

Occurs when your sampling rate is not high enough to capture the amount

  • f detail in your image

To do sampling right, need to understand the structure of your signal/image [Source: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 12 / 35

slide-17
SLIDE 17

Aliasing

Occurs when your sampling rate is not high enough to capture the amount

  • f detail in your image

To do sampling right, need to understand the structure of your signal/image The minimum sampling rate is called the Nyquist rate [Source: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 12 / 35

slide-18
SLIDE 18

Aliasing

Occurs when your sampling rate is not high enough to capture the amount

  • f detail in your image

To do sampling right, need to understand the structure of your signal/image The minimum sampling rate is called the Nyquist rate [Source: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 12 / 35

slide-19
SLIDE 19
  • Mr. Nyquist

Harry Nyquist says that one should look at the frequencies of the signal. One should find the highest frequency (via Fourier Transform) To sample properly you need to sample with at least twice that frequency For those interested: http://en.wikipedia.org/wiki/Nyquist%E2%80% 93Shannon_sampling_theorem He looks like a smart guy, we’ll just believe him

Sanja Fidler CSC420: Intro to Image Understanding 13 / 35

slide-20
SLIDE 20

2D example

Good sampling Bad sampling

[Source: N. Snavely]

Sanja Fidler CSC420: Intro to Image Understanding 14 / 35

slide-21
SLIDE 21

Going back to Downsampling ...

When downsampling by a factor of two, the original image has frequencies that are too high High frequencies are caused by sharp edges How can we fix this? [Adopted from: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 15 / 35

slide-22
SLIDE 22

Going back to Downsampling ...

When downsampling by a factor of two, the original image has frequencies that are too high High frequencies are caused by sharp edges How can we fix this? [Adopted from: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 15 / 35

slide-23
SLIDE 23

Gaussian pre-filtering

Solution: Blur the image via Gaussian, then subsample. Very simple!

!"#$%

!"###$# &%

'#!'()*"+% !"#$% '#!'()*"+% ,%

!%# !%###$# &%

!&#

!"#

[Source: N. Snavely]

Sanja Fidler CSC420: Intro to Image Understanding 16 / 35

slide-24
SLIDE 24

Subsampling with Gaussian pre-filtering

G 1/4 G 1/8 Gaussian 1/2

[Source: S. Seitz]

Sanja Fidler CSC420: Intro to Image Understanding 17 / 35

slide-25
SLIDE 25

Compare with ...

1/4 (2x zoom) 1/8 (4x zoom) 1/2

[Source: S. Seitz]

Sanja Fidler CSC420: Intro to Image Understanding 18 / 35

slide-26
SLIDE 26

Where is the Rectangle?

My image Figure: Dashed line denotes the border of the image (it’s not part of the image)

Sanja Fidler CSC420: Intro to Image Understanding 19 / 35

slide-27
SLIDE 27

Where is the Rectangle?

My image Let’s blur Figure: Dashed line denotes the border of the image (it’s not part of the image)

Sanja Fidler CSC420: Intro to Image Understanding 19 / 35

slide-28
SLIDE 28

Where is the Rectangle?

My image Let’s blur And now take every other row and column Figure: Dashed line denotes the border of the image (it’s not part of the image)

Sanja Fidler CSC420: Intro to Image Understanding 19 / 35

slide-29
SLIDE 29

Where is the Chicken?

My image

Sanja Fidler CSC420: Intro to Image Understanding 20 / 35

slide-30
SLIDE 30

Where is the Chicken?

My image Let’s blur

Sanja Fidler CSC420: Intro to Image Understanding 20 / 35

slide-31
SLIDE 31

Where is the Chicken?

My image Let’s blur And now take every other column

Sanja Fidler CSC420: Intro to Image Understanding 20 / 35

slide-32
SLIDE 32

Gaussian Pyramids [Burt and Adelson, 1983]

A sequence of images created with Gaussian blurring and downsampling is called a Gaussian Pyramid In computer graphics, a mip map [Williams, 1983] How much space does a Gaussian pyramid take compared to original image? [Source: S. Seitz]

Sanja Fidler CSC420: Intro to Image Understanding 21 / 35

slide-33
SLIDE 33

Gaussian Pyramids [Burt and Adelson, 1983]

A sequence of images created with Gaussian blurring and downsampling is called a Gaussian Pyramid In computer graphics, a mip map [Williams, 1983] How much space does a Gaussian pyramid take compared to original image? [Source: S. Seitz]

Sanja Fidler CSC420: Intro to Image Understanding 21 / 35

slide-34
SLIDE 34

Example of Gaussian Pyramid

[Source: N. Snavely]

Sanja Fidler CSC420: Intro to Image Understanding 22 / 35

slide-35
SLIDE 35

Image Up-Sampling

This image is too small, how can we make it 10 times as big?

[Source: N. Snavely, R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 23 / 35

slide-36
SLIDE 36

Image Up-Sampling

This image is too small, how can we make it 10 times as big? Simplest approach: repeat each row and column 10 times

[Source: N. Snavely, R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 23 / 35

slide-37
SLIDE 37

Interpolation

!" #" $" %" &"

d = 1 in this example

Recall how a digital image is formed F[x, y] = quantize{f (xd, yd)} It is a discrete point-sampling of a continuous function If we could somehow reconstruct the original function, any new image could be generated, at any resolution and scale [Source: N. Snavely, S. Seitz]

Sanja Fidler CSC420: Intro to Image Understanding 24 / 35

slide-38
SLIDE 38

Interpolation

!" #" $" %" &"

d = 1 in this example

Recall how a digital image is formed F[x, y] = quantize{f (xd, yd)} It is a discrete point-sampling of a continuous function If we could somehow reconstruct the original function, any new image could be generated, at any resolution and scale [Source: N. Snavely, S. Seitz]

Sanja Fidler CSC420: Intro to Image Understanding 24 / 35

slide-39
SLIDE 39

Interpolation

!" #" $" %" &"

d = 1 in this example

Recall how a digital image is formed F[x, y] = quantize{f (xd, yd)} It is a discrete point-sampling of a continuous function If we could somehow reconstruct the original function, any new image could be generated, at any resolution and scale [Source: N. Snavely, S. Seitz]

Sanja Fidler CSC420: Intro to Image Understanding 24 / 35

slide-40
SLIDE 40

Interpolation

What if we don’t know f ? [Source: N. Snavely, S. Seitz]

Sanja Fidler CSC420: Intro to Image Understanding 25 / 35

slide-41
SLIDE 41

Interpolation

What if we don’t know f ? Guess an approximation: for example nearest-neighbor [Source: N. Snavely, S. Seitz]

Sanja Fidler CSC420: Intro to Image Understanding 25 / 35

slide-42
SLIDE 42

Interpolation

What if we don’t know f ? Guess an approximation: for example nearest-neighbor Guess an approximation: for example linear [Source: N. Snavely, S. Seitz]

Sanja Fidler CSC420: Intro to Image Understanding 25 / 35

slide-43
SLIDE 43

Interpolation

What if we don’t know f ? Guess an approximation: for example nearest-neighbor Guess an approximation: for example linear More complex approximations: cubic, B-splines [Source: N. Snavely, S. Seitz]

Sanja Fidler CSC420: Intro to Image Understanding 25 / 35

slide-44
SLIDE 44

Linear Interpolation

Linear interpolation: G(x) = x2 − x x2 − x1 F(x1) + x − x1 x2 − x1 F(x2)

Sanja Fidler CSC420: Intro to Image Understanding 26 / 35

slide-45
SLIDE 45

Interpolation: 1D Example

Let’s make this signal triple length

Sanja Fidler CSC420: Intro to Image Understanding 27 / 35

slide-46
SLIDE 46

Interpolation: 1D Example

Let’s make this signal triple length (d = 3)

Sanja Fidler CSC420: Intro to Image Understanding 27 / 35

slide-47
SLIDE 47

Interpolation: 1D Example

Let’s make this signal triple length (d = 3) If i/d is an integer, just copy from the signal

Sanja Fidler CSC420: Intro to Image Understanding 27 / 35

slide-48
SLIDE 48

Interpolation: 1D Example

Let’s make this signal triple length (d = 3) If i/d is an integer, just copy from the signal Otherwise use the interpolation formula

Sanja Fidler CSC420: Intro to Image Understanding 27 / 35

slide-49
SLIDE 49

Linear Interpolation via Convolution

Linear interpolation: G(x) = x2 − x x2 − x1 F(x1) + x − x1 x2 − x1 F(x2) With t = x − x1 and d = x2 − x1 we can get: G(x) = d − t d F(x − t) + t d F(x + d − t)

Sanja Fidler CSC420: Intro to Image Understanding 28 / 35

slide-50
SLIDE 50

Linear Interpolation via Convolution

Linear interpolation: G(x) = x2 − x x2 − x1 F(x1) + x − x1 x2 − x1 F(x2) With t = x − x1 and d = x2 − x1 we can get: G(x) = d − t d F(x − t) + t d F(x + d − t) ( Kind of looks like convolution: G(x) =

t h(t)F(x − t) ) )

Sanja Fidler CSC420: Intro to Image Understanding 28 / 35

slide-51
SLIDE 51

Interpolation via Convolution: 1D Example

Let’s make this signal triple length

Sanja Fidler CSC420: Intro to Image Understanding 29 / 35

slide-52
SLIDE 52

Interpolation via Convolution: 1D Example

Let’s make this signal triple length (d = 3)

Sanja Fidler CSC420: Intro to Image Understanding 29 / 35

slide-53
SLIDE 53

Interpolation via Convolution: 1D Example

Let’s make this signal triple length (d = 3) What should be my “reconstruction” filter h (such that G = h ∗ G ′)?

Sanja Fidler CSC420: Intro to Image Understanding 29 / 35

slide-54
SLIDE 54

Interpolation via Convolution: 1D Example

Let’s make this signal triple length (d = 3) What should be my “reconstruction” filter h (such that G = h ∗ G ′)? h = [0, 1

d , . . . , d−1 d , 1, d−1 d , . . . , 1 d , 0], where d my upsampling factor

Sanja Fidler CSC420: Intro to Image Understanding 29 / 35

slide-55
SLIDE 55

Interpolation via Convolution: 1D Example

Let’s make this signal triple length (d = 3) What should be my “reconstruction” filter h (such that G = h ∗ G ′)? h = [0, 1

d , . . . , d−1 d , 1, d−1 d , . . . , 1 d , 0], where d my upsampling factor

Sanja Fidler CSC420: Intro to Image Understanding 29 / 35

slide-56
SLIDE 56

Interpolation via Convolution: 1D Example

Let’s make this signal triple length (d = 3) What should be my “reconstruction” filter h (such that G = h ∗ G ′)? h = [0, 1

d , . . . , d−1 d , 1, d−1 d , . . . , 1 d , 0], where d my upsampling factor

Sanja Fidler CSC420: Intro to Image Understanding 29 / 35

slide-57
SLIDE 57

Interpolation via Convolution: 1D Example

Let’s make this signal triple length (d = 3) What should be my “reconstruction” filter h (such that G = h ∗ G ′)? h = [0, 1

d , . . . , d−1 d , 1, d−1 d , . . . , 1 d , 0], where d my upsampling factor

Sanja Fidler CSC420: Intro to Image Understanding 29 / 35

slide-58
SLIDE 58

Interpolation via Convolution (1D)

!"#$%&'()$*+,-.)/*0+,( 1$%)$-.2,$3456+)( 3,.$)7+&%0+,( 83,$%)(3,.$)7+&%0+,( 9%/--3%,()$*+,-.)/*0+,(

:+/)*$;(<=(>/)&$--(

Sanja Fidler CSC420: Intro to Image Understanding 30 / 35

slide-59
SLIDE 59

Image Interpolation (2D)

Let’s make this image triple size Copy image in every third pixel. What about the remaining pixels in G?

Sanja Fidler CSC420: Intro to Image Understanding 31 / 35

slide-60
SLIDE 60

Image Interpolation (2D)

Let’s make this image triple size Copy image in every third pixel. What about the remaining pixels in G? How shall we compute this value?

Sanja Fidler CSC420: Intro to Image Understanding 31 / 35

slide-61
SLIDE 61

Image Interpolation (2D)

Let’s make this image triple size Copy image in every third pixel. What about the remaining pixels in G? One possible way: nearest neighbor interpolation

Sanja Fidler CSC420: Intro to Image Understanding 31 / 35

slide-62
SLIDE 62

Image Interpolation (2D)

Let’s make this image triple size Copy image in every third pixel. What about the remaining pixels in G? Better: bilinear interpolation (check out details: http://en.wikipedia.org/wiki/Bilinear_interpolation)

Sanja Fidler CSC420: Intro to Image Understanding 31 / 35

slide-63
SLIDE 63

Reconstruction Filters

What does the 2D version of this hat function look like?

!"#$%#&'(( )*+",#(*+-"#!%),.%+( /-"+-($0+1.%+2(!"#$%#&'(( !"#"$%&'("$)%'*+#&,+$(

Sanja Fidler CSC420: Intro to Image Understanding 32 / 35

slide-64
SLIDE 64

Reconstruction Filters

What does the 2D version of this hat function look like?

!"#$%#&'(( )*+",#(*+-"#!%),.%+( /-"+-($0+1.%+2(!"#$%#&'(( !"#"$%&'("$)%'*+#&,+$(

And filter for nearest neighbor interpolation?

Sanja Fidler CSC420: Intro to Image Understanding 32 / 35

slide-65
SLIDE 65

Reconstruction Filters

What does the 2D version of this hat function look like?

!"#$%#&'(( )*+",#(*+-"#!%),.%+( /-"+-($0+1.%+2(!"#$%#&'(( !"#"$%&'("$)%'*+#&,+$(

And filter for nearest neighbor interpolation?

Sanja Fidler CSC420: Intro to Image Understanding 32 / 35

slide-66
SLIDE 66

Reconstruction Filters

What does the 2D version of this hat function look like?

!"#$%#&'(( )*+",#(*+-"#!%),.%+( /-"+-($0+1.%+2(!"#$%#&'(( !"#"$%&'("$)%'*+#&,+$(

Better filters give better resampled images: Bicubic is a common choice

Sanja Fidler CSC420: Intro to Image Understanding 32 / 35

slide-67
SLIDE 67

Image Interpolation via Convolution (2D)

Let’s make this image triple size: copy image values in every third pixel, place zeros everywhere else

Sanja Fidler CSC420: Intro to Image Understanding 33 / 35

slide-68
SLIDE 68

Image Interpolation via Convolution (2D)

Let’s make this image triple size: copy image values in every third pixel, place zeros everywhere else Convolution with a reconstruction filter (e.g., bilinear) and you get the interpolated image

Sanja Fidler CSC420: Intro to Image Understanding 33 / 35

slide-69
SLIDE 69

Image Interpolation

Original image Interpolation results

!"#$"%&'(")*+,-$.)(&"$/-0#1-(. 2)0)("#$.)(&"$/-0#1-(. 2)34,)3.)(&"$/-0#1-(.

[Source: N. Snavely]

Sanja Fidler CSC420: Intro to Image Understanding 34 / 35

slide-70
SLIDE 70

Summary – Stuff You Should Know

To down-scale an image: blur it with a small Gaussian (e.g., σ = 1.4) and downsample To up-scale an image: interpolation (nearest neighbor, bilinear, bicubic, etc) Gaussian pyramid: Blur with Gaussian filter, downsample result by factor 2, blur it with the Gaussian, downsample by 2...

Matlab functions:

fspecial: creates a Gaussian filter with specified σ imfilter: convolve image with the filter I(1:2:end, 1:2:end): takes every second row and column imresize(image, scale, method): Matlab’s function for resizing the image, where method=“nearest”, “bilinear”, “bicubic” (works for downsampling and upsampling)

Sanja Fidler CSC420: Intro to Image Understanding 35 / 35