+ All Categories
Home > Documents > Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any...

Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any...

Date post: 11-Jul-2020
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
121
Cameras and Images Sanja Fidler CSC420: Intro to Image Understanding 1 / 58
Transcript
Page 1: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Cameras and Images

Sanja Fidler CSC420: Intro to Image Understanding 1 / 58

Page 2: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Pinhole Camera

[Source: A. Torralba]

Make your own camera

http://www.foundphotography.com/PhotoThoughts/archives/2005/

04/pinhole_camera_2.html

Sanja Fidler CSC420: Intro to Image Understanding 2 / 58

Page 3: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Pinhole Camera – How It Works

[Source: A. Torralba]

The pinhole camera only allows rays from one point in the scene

to strike each point of the paper.

Sanja Fidler CSC420: Intro to Image Understanding 3 / 58

Page 4: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Pinhole Camera – How It Works

[Source: A. Torralba]

ExampleSanja Fidler CSC420: Intro to Image Understanding 4 / 58

Page 5: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Pinhole Camera – Example

[Source: A. Torralba]

Sanja Fidler CSC420: Intro to Image Understanding 5 / 58

Page 6: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Pinhole Camera

[Source: A. Torralba]

You can make it stereo

Sanja Fidler CSC420: Intro to Image Understanding 6 / 58

Page 7: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Pinhole Camera – Stereo Example

[Source: A. Torralba]

Try it with 3D glasses!

Sanja Fidler CSC420: Intro to Image Understanding 7 / 58

Page 8: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Pinhole Camera

[Source: A. Torralba]

Remember this example?

In this case the window acts as a pinhole camera into the room

Sanja Fidler CSC420: Intro to Image Understanding 8 / 58

Page 9: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Digital Camera

[Adopted from S. Seitz]

A digital camera replaces film with a sensor array

Each cell in the array is a light-sensitive diode that converts

photons to electrons

http://electronics.howstuffworks.com/cameras-photography/

digital/digital-camera.htm

Sanja Fidler CSC420: Intro to Image Understanding 9 / 58

Page 10: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Image Formation

Image formation process producing a particular image depends on:

lighting conditions

scene geometry

surface properties

camera optics

Sanja Fidler CSC420: Intro to Image Understanding 10 / 58

Page 11: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Digital Image

Continuous image projected to sensor array

Sampling and quantization

http://pho.to/media/images/digital/digital-sensors.jpg

Sample the 2D space on a regular grid

Quantize each sample (round to nearest integer)

Sanja Fidler CSC420: Intro to Image Understanding 11 / 58

Page 12: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Digital Image

Image is a matrix with integer values

We will typically denote it with I

I (i , j) is called intensity

Matrix I can be m ⇥ n (grayscale)

or m ⇥ n ⇥ 3 (color)

Sanja Fidler CSC420: Intro to Image Understanding 12 / 58

Page 13: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Digital Image

Image is a matrix with integer values

We will typically denote it with I

I (i , j) is called intensity

Matrix I can be m ⇥ n (grayscale)

or m ⇥ n ⇥ 3 (color)

Sanja Fidler CSC420: Intro to Image Understanding 12 / 58

Page 14: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Digital Image

Image is a matrix with integer values

We will typically denote it with I

I (i , j) is called intensity

Matrix I can be m ⇥ n (grayscale)

or m ⇥ n ⇥ 3 (color)

Sanja Fidler CSC420: Intro to Image Understanding 12 / 58

Page 15: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Digital Image

Image is a matrix with integer values

We will typically denote it with I

I (i , j) is called intensity

Matrix I can be m ⇥ n (grayscale)

or m ⇥ n ⇥ 3 (color)

Sanja Fidler CSC420: Intro to Image Understanding 12 / 58

Page 16: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Digital Image

Image is a matrix with integer values

We will typically denote it with I

I (i , j) is called intensity

Matrix I can be m ⇥ n (grayscale)

or m ⇥ n ⇥ 3 (color)

Sanja Fidler CSC420: Intro to Image Understanding 12 / 58

Page 17: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Intensity

We can think of a (grayscale) image as a function f : R2 ! R givingthe intensity at position (i , j)Intensity 0 is black and 255 is white

Sanja Fidler CSC420: Intro to Image Understanding 13 / 58

Page 18: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Image Transformations

As with any function, we can apply operators to an image, e.g.:

We’ll talk about special kinds of operators, correlation and

convolution (linear filtering)

[Adapted from: N. Snavely]

Sanja Fidler CSC420: Intro to Image Understanding 14 / 58

Page 19: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Image Transformations

As with any function, we can apply operators to an image, e.g.:

We’ll talk about special kinds of operators, correlation and

convolution (linear filtering)

[Adapted from: N. Snavely]

Sanja Fidler CSC420: Intro to Image Understanding 14 / 58

Page 20: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Image Transformations

As with any function, we can apply operators to an image, e.g.:

We’ll talk about special kinds of operators, correlation and

convolution (linear filtering)

[Adapted from: N. Snavely]

Sanja Fidler CSC420: Intro to Image Understanding 14 / 58

Page 21: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Image Transformations

As with any function, we can apply operators to an image, e.g.:

We’ll talk about special kinds of operators, correlation and

convolution (linear filtering)

[Adapted from: N. Snavely]

Sanja Fidler CSC420: Intro to Image Understanding 14 / 58

Page 22: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Linear Filters

Reading: Szeliski book, Chapter 3.2

Sanja Fidler CSC420: Intro to Image Understanding 15 / 58

Page 23: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Motivation: Finding Waldo

How can we find Waldo?

[Source: R. Urtasun]Sanja Fidler CSC420: Intro to Image Understanding 16 / 58

Page 24: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Answer

Slide and compare!

In formal language: filtering

Sanja Fidler CSC420: Intro to Image Understanding 17 / 58

Page 25: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Motivation: Noise reduction

Given a camera and a still scene, how can you reduce noise?

[Source: S. Seitz]

Sanja Fidler CSC420: Intro to Image Understanding 18 / 58

Page 26: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Image Filtering

Modify the pixels in an image based on some function of a localneighborhood of each pixel

In other words... Filtering

!" #"$"

#" %"#"

!" &"#'"

()*+,"-.+/0"1+2+"

%"

3)1-401"-.+/0"1+2+"

5).0"678*9)8"

[Source: L. Zhang]

Sanja Fidler CSC420: Intro to Image Understanding 19 / 58

Page 27: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Applications of Filtering

Enhance an image, e.g., denoise.

Detect patterns, e.g., template matching.

Extract information, e.g., texture, edges.

Filtering is used in Convolutional Neural Networks

Sanja Fidler CSC420: Intro to Image Understanding 20 / 58

Page 28: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Applications of Filtering

Enhance an image, e.g., denoise. Let’s talk about this first

Detect patterns, e.g., template matching.

Extract information, e.g., texture, edges.

Sanja Fidler CSC420: Intro to Image Understanding 20 / 58

Page 29: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Noise reduction

Simplest thing: replace each pixel by the average of its neighbors.

This assumes that neighboring pixels are similar, and the noise to beindependent from pixel to pixel.

[Source: S. Marschner]

Sanja Fidler CSC420: Intro to Image Understanding 21 / 58

Page 30: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Noise reduction

Simplest thing: replace each pixel by the average of its neighbors.

This assumes that neighboring pixels are similar, and the noise to beindependent from pixel to pixel.

[Source: S. Marschner]

Sanja Fidler CSC420: Intro to Image Understanding 21 / 58

Page 31: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Noise reduction

Simplest thing: replace each pixel by the average of its neighbors

This assumes that neighboring pixels are similar, and the noise to beindependent from pixel to pixel.

Moving average in 1D: [1, 1, 1, 1, 1]/5

[Source: S. Marschner]

Sanja Fidler CSC420: Intro to Image Understanding 22 / 58

Page 32: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Noise reduction

Simplest thing: replace each pixel by the average of its neighbors

This assumes that neighboring pixels are similar, and the noise to beindependent from pixel to pixel.

Non-uniform weights [1, 4, 6, 4, 1] / 16

[Source: S. Marschner]

Sanja Fidler CSC420: Intro to Image Understanding 23 / 58

Page 33: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Moving Average in 2D

[Source: S. Seitz]

Sanja Fidler CSC420: Intro to Image Understanding 24 / 58

Page 34: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Moving Average in 2D

[Source: S. Seitz]

Sanja Fidler CSC420: Intro to Image Understanding 24 / 58

Page 35: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Moving Average in 2D

[Source: S. Seitz]

Sanja Fidler CSC420: Intro to Image Understanding 24 / 58

Page 36: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Moving Average in 2D

[Source: S. Seitz]

Sanja Fidler CSC420: Intro to Image Understanding 24 / 58

Page 37: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Moving Average in 2D

[Source: S. Seitz]

Sanja Fidler CSC420: Intro to Image Understanding 24 / 58

Page 38: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Moving Average in 2D

[Source: S. Seitz]

Sanja Fidler CSC420: Intro to Image Understanding 24 / 58

Page 39: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Linear Filtering: Correlation

Involves weighted combinations of pixels in small neighborhoods:

G (i , j) =1

(2k + 1)2

kX

u=�k

kX

v=�k

I (i + u, j + v)

The output pixels value is determined as a weighted sum of inputpixel values

G (i , j) =kX

u=�k

kX

v=�k

F (u, v) · I (i + u, j + v)

The entries of the weight kernel or mask F (u, v) are often called thefilter coe�cients.This operator is the correlation operator

G = F ⌦ I

Sanja Fidler CSC420: Intro to Image Understanding 25 / 58

Page 40: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Linear Filtering: Correlation

Involves weighted combinations of pixels in small neighborhoods:

G (i , j) =1

(2k + 1)2

kX

u=�k

kX

v=�k

I (i + u, j + v)

The output pixels value is determined as a weighted sum of inputpixel values

G (i , j) =kX

u=�k

kX

v=�k

F (u, v) · I (i + u, j + v)

The entries of the weight kernel or mask F (u, v) are often called thefilter coe�cients.

This operator is the correlation operator

G = F ⌦ I

Sanja Fidler CSC420: Intro to Image Understanding 25 / 58

Page 41: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Linear Filtering: Correlation

Involves weighted combinations of pixels in small neighborhoods:

G (i , j) =1

(2k + 1)2

kX

u=�k

kX

v=�k

I (i + u, j + v)

The output pixels value is determined as a weighted sum of inputpixel values

G (i , j) =kX

u=�k

kX

v=�k

F (u, v) · I (i + u, j + v)

The entries of the weight kernel or mask F (u, v) are often called thefilter coe�cients.This operator is the correlation operator

G = F ⌦ I

Sanja Fidler CSC420: Intro to Image Understanding 25 / 58

Page 42: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Linear Filtering: Correlation

Involves weighted combinations of pixels in small neighborhoods:

G (i , j) =1

(2k + 1)2

kX

u=�k

kX

v=�k

I (i + u, j + v)

The output pixels value is determined as a weighted sum of inputpixel values

G (i , j) =kX

u=�k

kX

v=�k

F (u, v) · I (i + u, j + v)

The entries of the weight kernel or mask F (u, v) are often called thefilter coe�cients.This operator is the correlation operator

G = F ⌦ I

Sanja Fidler CSC420: Intro to Image Understanding 25 / 58

Page 43: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Linear Filtering: Correlation

It’s really easy!

Sanja Fidler CSC420: Intro to Image Understanding 26 / 58

Page 44: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Linear Filtering: Correlation

It’s really easy!

Sanja Fidler CSC420: Intro to Image Understanding 26 / 58

Page 45: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Linear Filtering: Correlation

It’s really easy!

Sanja Fidler CSC420: Intro to Image Understanding 26 / 58

Page 46: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Linear Filtering: Correlation

It’s really easy!

G (i , j) =kX

u=�k

kX

v=�k

F (u, v) · I (i + u, j + v)

Sanja Fidler CSC420: Intro to Image Understanding 26 / 58

Page 47: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Linear Filtering: Correlation

What happens along the borders of the image?

G (i , j) =kX

u=�k

kX

v=�k

F (u, v) · I (i + u, j + v)

Sanja Fidler CSC420: Intro to Image Understanding 26 / 58

Page 48: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Boundary E↵ects

What happens at the border of the image? What’s the size of theoutput matrix?

MATLAB: filter2(g, f, shape)

shape = “full” output size is sum of sizes of f and g

shape = “same”: output size is same as f

shape = “valid”: output size is di↵erence of sizes of f and g

[Source: S. Lazebnik]

Sanja Fidler CSC420: Intro to Image Understanding 27 / 58

Page 49: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Boundary E↵ects

What happens at the border of the image? What’s the size of theoutput matrix?MATLAB: filter2(g, f, shape)shape = “full” output size is sum of sizes of f and g

shape = “same”: output size is same as fshape = “valid”: output size is di↵erence of sizes of f and g

[Source: S. Lazebnik]Sanja Fidler CSC420: Intro to Image Understanding 27 / 58

Page 50: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Filtering with Correlation: Example

What’s the result?

[Source: D. Lowe]

Sanja Fidler CSC420: Intro to Image Understanding 28 / 58

Page 51: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Filtering with Correlation: Example

What’s the result?

[Source: D. Lowe]

Sanja Fidler CSC420: Intro to Image Understanding 28 / 58

Page 52: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Filtering with Correlation: Example

What’s the result?

[Source: D. Lowe]

Sanja Fidler CSC420: Intro to Image Understanding 28 / 58

Page 53: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Filtering with Correlation: Example

What’s the result?

[Source: D. Lowe]

Sanja Fidler CSC420: Intro to Image Understanding 28 / 58

Page 54: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Filtering with Correlation: Example

What’s the result?

Original!

!"!"!"

!"!"!"

!"!"!"

#"#"#"

#"$"#"

#"#"#" -! %"* [Source: D. Lowe]

Sanja Fidler CSC420: Intro to Image Understanding 28 / 58

Page 55: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Filtering with Correlation: Example

What’s the result?

Original!

!"!"!"

!"!"!"

!"!"!"

#"#"#"

#"$"#"

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

%&''()*+&*(,"(-.(,/*

0"* [Source: D. Lowe]

Sanja Fidler CSC420: Intro to Image Understanding 28 / 58

Page 56: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Sharpening

[Source: D. Lowe]

Sanja Fidler CSC420: Intro to Image Understanding 29 / 58

Page 57: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Sharpening

!"#$%&'&()

#$%&'&()

[Source: N. Snavely]

Sanja Fidler CSC420: Intro to Image Understanding 30 / 58

Page 58: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Example of Correlation

What is the result of filtering the impulse signal (image) I with thearbitrary filter F?

[Source: K. Grauman]

Sanja Fidler CSC420: Intro to Image Understanding 31 / 58

Page 59: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Smoothing by averaging

What if the filter size was 5 x 5 instead of 3 x 3?

[Source: K. Graumann]Sanja Fidler CSC420: Intro to Image Understanding 32 / 58

Page 60: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Gaussian filter

What if we want nearest neighboring pixels to have the most influenceon the output?

Removes high-frequency components from the image (low-pass filter).

[Source: S. Seitz]Sanja Fidler CSC420: Intro to Image Understanding 33 / 58

Page 61: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Smoothing with a Gaussian

[Source: K. Grauman]

Sanja Fidler CSC420: Intro to Image Understanding 34 / 58

Page 62: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Mean vs Gaussian

Sanja Fidler CSC420: Intro to Image Understanding 35 / 58

Page 63: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Gaussian filter: Parameters

Size of filter or mask: Gaussian function has infinite support, butdiscrete filters use finite kernels.

[Source: K. Grauman]

Sanja Fidler CSC420: Intro to Image Understanding 36 / 58

Page 64: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Gaussian filter: Parameters

Variance of the Gaussian: determines extent of smoothing.

[Source: K. Grauman]

Sanja Fidler CSC420: Intro to Image Understanding 37 / 58

Page 65: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Gaussian filter: Parameters

[Source: K. Grauman]

Sanja Fidler CSC420: Intro to Image Understanding 38 / 58

Page 66: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Is this the most general Gaussian?

No, the most general form for x 2 <d

N (x; µ,⌃) =1

(2⇡)d/2|⌃|1/2exp

✓�1

2(x� µ)T⌃�1(x� µ)

But the simplified version is typically used for filtering.

Sanja Fidler CSC420: Intro to Image Understanding 39 / 58

Page 67: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Properties of the Smoothing

All values are positive.

They all sum to 1.

Amount of smoothing proportional to mask size.

Remove high-frequency components; low-pass filter.

Sanja Fidler CSC420: Intro to Image Understanding 40 / 58

Page 68: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Properties of the Smoothing

All values are positive.

They all sum to 1.

Amount of smoothing proportional to mask size.

Remove high-frequency components; low-pass filter.

Sanja Fidler CSC420: Intro to Image Understanding 40 / 58

Page 69: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Properties of the Smoothing

All values are positive.

They all sum to 1.

Amount of smoothing proportional to mask size.

Remove high-frequency components; low-pass filter.

Sanja Fidler CSC420: Intro to Image Understanding 40 / 58

Page 70: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Properties of the Smoothing

All values are positive.

They all sum to 1.

Amount of smoothing proportional to mask size.

Remove high-frequency components; low-pass filter.

Sanja Fidler CSC420: Intro to Image Understanding 40 / 58

Page 71: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Finding Waldo

image I

How can we use what we just learned to find Waldo?

Sanja Fidler CSC420: Intro to Image Understanding 41 / 58

Page 72: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Finding Waldo

image I filter F

Is correlation a good choice?

Sanja Fidler CSC420: Intro to Image Understanding 41 / 58

Page 73: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

A Slight Detour: Correlation in Matrix Form

Remember correlation:

G (i , j) =kX

u=�k

kX

v=�k

F (u, v) · I (i + u, j + v)

Can we write that in a more compact form (with vectors)?

Sanja Fidler CSC420: Intro to Image Understanding 42 / 58

Page 74: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

A Slight Detour: Correlation in Matrix Form

Remember correlation:

G (i , j) =kX

u=�k

kX

v=�k

F (u, v) · I (i + u, j + v)

Sanja Fidler CSC420: Intro to Image Understanding 42 / 58

Page 75: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

A Slight Detour: Correlation in Matrix Form

Remember correlation:

G (i , j) =kX

u=�k

kX

v=�k

F (u, v) · I (i + u, j + v)

Sanja Fidler CSC420: Intro to Image Understanding 42 / 58

Page 76: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

A Slight Detour: Correlation in Matrix Form

Remember correlation:

G (i , j) =kX

u=�k

kX

v=�k

F (u, v) · I (i + u, j + v)

G (i , j) = fT · tij

Sanja Fidler CSC420: Intro to Image Understanding 42 / 58

Page 77: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

A Slight Detour: Correlation in Matrix Form

Remember correlation:

G (i , j) =kX

u=�k

kX

v=�k

F (u, v) · I (i + u, j + v)

Can we write that in a more compact form (with vectors)?

Define f = F (:), Tij

= I (i � k : i + k , j � k : j + k), and tij

= T

ij

(:)

G (i , j) = fT · tij

where · is a dot product

Sanja Fidler CSC420: Intro to Image Understanding 42 / 58

Page 78: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

A Slight Detour: Correlation in Matrix Form

Remember correlation:

G (i , j) =kX

u=�k

kX

v=�k

F (u, v) · I (i + u, j + v)

Can we write that in a more compact form (with vectors)?

Define f = F (:), Tij

= I (i � k : i + k , j � k : j + k), and tij

= T

ij

(:)

G (i , j) = fT · tij

where · is a dot product

Homework: Can we write full correlation G = F ⌦ I in matrix form?

Sanja Fidler CSC420: Intro to Image Understanding 42 / 58

Page 79: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

A Slight Detour: Correlation in Matrix Form

Remember correlation:

G (i , j) =kX

u=�k

kX

v=�k

F (u, v) · I (i + u, j + v)

Can we write that in a more compact form (with vectors)?

Define f = F (:), Tij

= I (i � k : i + k , j � k : j + k), and tij

= T

ij

(:)

G (i , j) = fT · tij

where · is a dot product

Finding Waldo: How could we ensure to get the best “score” (e.g. 1)

for an image crop that looks exactly like our filter?

Sanja Fidler CSC420: Intro to Image Understanding 42 / 58

Page 80: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

A Slight Detour: Correlation in Matrix Form

Remember correlation:

G (i , j) =kX

u=�k

kX

v=�k

F (u, v) · I (i + u, j + v)

Can we write that in a more compact form (with vectors)?

Define f = F (:), Tij

= I (i � k : i + k , j � k : j + k), and tij

= T

ij

(:)

G (i , j) = fT · tij

where · is a dot product

Finding Waldo: How could we ensure to get the best “score” (e.g. 1)

for an image crop that looks exactly like our filter?

Normalized cross-correlation:

G (i , j) =fT · t

ij

||f|| · ||tij||Sanja Fidler CSC420: Intro to Image Understanding 42 / 58

Page 81: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Back to Waldo

image I filter F

Sanja Fidler CSC420: Intro to Image Understanding 43 / 58

Page 82: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Back to Waldo

Result of normalized cross-correlation

Sanja Fidler CSC420: Intro to Image Understanding 43 / 58

Page 83: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Back to Waldo

Find the highest peak

Sanja Fidler CSC420: Intro to Image Understanding 43 / 58

Page 84: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Back to Waldo

And put a bounding box (rectangle the size of the template) at the point!

Sanja Fidler CSC420: Intro to Image Understanding 43 / 58

Page 85: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Back to Waldo

Homework: Do it yourself! Code on class webpage. Don’t cheat ;)

Sanja Fidler CSC420: Intro to Image Understanding 43 / 58

Page 86: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Convolution

Convolution operator

G (i , j) =kX

u=�k

kX

v=�k

F (u, v) · I (i � u, j � v)

Sanja Fidler CSC420: Intro to Image Understanding 44 / 58

Page 87: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Convolution

Convolution operator

G (i , j) =kX

u=�k

kX

v=�k

F (u, v) · I (i � u, j � v)

Equivalent to flipping the filter in both dimensions (bottom to top,right to left) and apply correlation.

Sanja Fidler CSC420: Intro to Image Understanding 44 / 58

Page 88: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Correlation vs Convolution

Correlation

=

Convolution

Sanja Fidler CSC420: Intro to Image Understanding 45 / 58

Page 89: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Correlation vs Convolution

For a Gaussian or box filter, how will the outputs F ⇤ I and F ⌦ I di↵er?

Sanja Fidler CSC420: Intro to Image Understanding 45 / 58

Page 90: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Correlation vs Convolution

For a Gaussian or box filter, how will the outputs F ⇤ I and F ⌦ I di↵er?

How will the outputs di↵er for: 0

B@0 0 0

0 0 1

0 0 0

1

CA

Sanja Fidler CSC420: Intro to Image Understanding 45 / 58

Page 91: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Correlation vs Convolution

For a Gaussian or box filter, how will the outputs F ⇤ I and F ⌦ I di↵er?

How will the outputs di↵er for: 0

B@0 0 0

0 0 1

0 0 0

1

CA

If the input is an impulse signal, how will the outputs di↵er? � ⇤ I and � ⌦ I?

Sanja Fidler CSC420: Intro to Image Understanding 45 / 58

Page 92: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

”Optical” Convolution

Camera Shake

* !"Figure: Fergus, et al., SIGGRAPH 2006

Blur in out-of-focus regions of an image.

Figure: Bokeh: http://lullaby.homepage.dk/diy-camera/bokeh.htmlClick for more info

[Source: N. Snavely]Sanja Fidler CSC420: Intro to Image Understanding 46 / 58

Page 93: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Properties of Convolution

Commutative : f ⇤ g = g ⇤ fAssociative : f ⇤ (g ⇤ h) = (f ⇤ g) ⇤ hDistributive : f ⇤ (g + h) = f ⇤ g + f ⇤ h

Assoc. with scalar multiplier : � · (f ⇤ g) = (� · f ) ⇤ h

The Fourier transform of two convolved images is the product of theirindividual Fourier transforms:

F(f ⇤ g) = F(f ) · F(g)

Homework: Why is this good news?

Hint: Think of complexity of convolution and Fourier Transform

Both correlation and convolution are linear shift-invariant (LSI)operators: the e↵ect of the operator is the same everywhere.

Sanja Fidler CSC420: Intro to Image Understanding 47 / 58

Page 94: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Properties of Convolution

Commutative : f ⇤ g = g ⇤ fAssociative : f ⇤ (g ⇤ h) = (f ⇤ g) ⇤ hDistributive : f ⇤ (g + h) = f ⇤ g + f ⇤ h

Assoc. with scalar multiplier : � · (f ⇤ g) = (� · f ) ⇤ h

The Fourier transform of two convolved images is the product of theirindividual Fourier transforms:

F(f ⇤ g) = F(f ) · F(g)

Homework: Why is this good news?

Hint: Think of complexity of convolution and Fourier Transform

Both correlation and convolution are linear shift-invariant (LSI)operators: the e↵ect of the operator is the same everywhere.

Sanja Fidler CSC420: Intro to Image Understanding 47 / 58

Page 95: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Properties of Convolution

Commutative : f ⇤ g = g ⇤ fAssociative : f ⇤ (g ⇤ h) = (f ⇤ g) ⇤ hDistributive : f ⇤ (g + h) = f ⇤ g + f ⇤ h

Assoc. with scalar multiplier : � · (f ⇤ g) = (� · f ) ⇤ h

The Fourier transform of two convolved images is the product of theirindividual Fourier transforms:

F(f ⇤ g) = F(f ) · F(g)

Homework: Why is this good news?

Hint: Think of complexity of convolution and Fourier Transform

Both correlation and convolution are linear shift-invariant (LSI)operators: the e↵ect of the operator is the same everywhere.

Sanja Fidler CSC420: Intro to Image Understanding 47 / 58

Page 96: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Gaussian Filter

Convolving twice with Gaussian kernel of width � is the same asconvolving once with kernel of width �

p2

* !"We don’t need to filter twice, just once with a bigger kernel

[Source: K. Grauman]

Sanja Fidler CSC420: Intro to Image Understanding 48 / 58

Page 97: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Separable Filters: Speed-up Trick!

The process of performing a convolution requires K 2 operations per

pixel, where K is the size (width or height) of the convolution filter.

Can we do faster?

In many cases (not all!), this operation can be speed up by first

performing a 1D horizontal convolution followed by a 1D vertical

convolution, requiring only 2K operations.

If this is possible, then the convolution filter is called separable.

And it is the outer product of two filters:

F = v hT

Homework: Think why in the case of separable filters 2D

convolution is the same as two 1D convolutions

[Source: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 49 / 58

Page 98: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Separable Filters: Speed-up Trick!

The process of performing a convolution requires K 2 operations per

pixel, where K is the size (width or height) of the convolution filter.

Can we do faster?

In many cases (not all!), this operation can be speed up by first

performing a 1D horizontal convolution followed by a 1D vertical

convolution, requiring only 2K operations.

If this is possible, then the convolution filter is called separable.

And it is the outer product of two filters:

F = v hT

Homework: Think why in the case of separable filters 2D

convolution is the same as two 1D convolutions

[Source: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 49 / 58

Page 99: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Separable Filters: Speed-up Trick!

The process of performing a convolution requires K 2 operations per

pixel, where K is the size (width or height) of the convolution filter.

Can we do faster?

In many cases (not all!), this operation can be speed up by first

performing a 1D horizontal convolution followed by a 1D vertical

convolution, requiring only 2K operations.

If this is possible, then the convolution filter is called separable.

And it is the outer product of two filters:

F = v hT

Homework: Think why in the case of separable filters 2D

convolution is the same as two 1D convolutions

[Source: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 49 / 58

Page 100: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Separable Filters: Speed-up Trick!

The process of performing a convolution requires K 2 operations per

pixel, where K is the size (width or height) of the convolution filter.

Can we do faster?

In many cases (not all!), this operation can be speed up by first

performing a 1D horizontal convolution followed by a 1D vertical

convolution, requiring only 2K operations.

If this is possible, then the convolution filter is called separable.

And it is the outer product of two filters:

F = v hT

Homework: Think why in the case of separable filters 2D

convolution is the same as two 1D convolutions

[Source: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 49 / 58

Page 101: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Separable Filters: Speed-up Trick!

The process of performing a convolution requires K 2 operations per

pixel, where K is the size (width or height) of the convolution filter.

Can we do faster?

In many cases (not all!), this operation can be speed up by first

performing a 1D horizontal convolution followed by a 1D vertical

convolution, requiring only 2K operations.

If this is possible, then the convolution filter is called separable.

And it is the outer product of two filters:

F = v hT

Homework: Think why in the case of separable filters 2D

convolution is the same as two 1D convolutions

[Source: R. Urtasun]Sanja Fidler CSC420: Intro to Image Understanding 49 / 58

Page 102: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

How it Works

Sanja Fidler CSC420: Intro to Image Understanding 50 / 58

Page 103: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

How it Works

Sanja Fidler CSC420: Intro to Image Understanding 50 / 58

Page 104: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

How it Works

Sanja Fidler CSC420: Intro to Image Understanding 50 / 58

Page 105: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

How it Works

Sanja Fidler CSC420: Intro to Image Understanding 50 / 58

Page 106: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Separable Filters: Gaussian filters

One famous separable filter we already know:

Gaussian : f (x , y) = 1

2⇡�2

e

� x

2

+y

2

�2

Sanja Fidler CSC420: Intro to Image Understanding 51 / 58

Page 107: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Separable Filters: Gaussian filters

One famous separable filter we already know:

Gaussian : f (x , y) = 1

2⇡�2

e

� x

2

+y

2

�2

=�

1p2⇡�

e

� x

2

�2

�·�

1p2⇡�

e

� y

2

�2

Sanja Fidler CSC420: Intro to Image Understanding 51 / 58

Page 108: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Let’s play a game...

Is this separable? If yes, what’s the separable version?

[Source: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 52 / 58

Page 109: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Let’s play a game...

Is this separable? If yes, what’s the separable version?

What does this filter do?

[Source: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 52 / 58

Page 110: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Let’s play a game...

Is this separable? If yes, what’s the separable version?

[Source: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 53 / 58

Page 111: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Let’s play a game...

Is this separable? If yes, what’s the separable version?

What does this filter do?

[Source: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 53 / 58

Page 112: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Let’s play a game...

Is this separable? If yes, what’s the separable version?

[Source: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 54 / 58

Page 113: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Let’s play a game...

Is this separable? If yes, what’s the separable version?

What does this filter do?

[Source: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 54 / 58

Page 114: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

How can we tell if a given filter F is indeed separable?

Inspection... this is what we were doing.

Looking at the analytic form of it.

Look at the singular value decomposition (SVD), and if only one

singular value is non-zero, then it is separable

F = U⌃VT =X

i

�i

u

i

v

T

i

with ⌃ = diag(�i

).

Matlab: [U,S,V] = svd(F);

p�1

u1

andp�1

vT1

are the vertical and horizontal filter.

[Source: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 55 / 58

Page 115: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

How can we tell if a given filter F is indeed separable?

Inspection... this is what we were doing.

Looking at the analytic form of it.

Look at the singular value decomposition (SVD), and if only one

singular value is non-zero, then it is separable

F = U⌃VT =X

i

�i

u

i

v

T

i

with ⌃ = diag(�i

).

Matlab: [U,S,V] = svd(F);

p�1

u1

andp�1

vT1

are the vertical and horizontal filter.

[Source: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 55 / 58

Page 116: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

How can we tell if a given filter F is indeed separable?

Inspection... this is what we were doing.

Looking at the analytic form of it.

Look at the singular value decomposition (SVD), and if only one

singular value is non-zero, then it is separable

F = U⌃VT =X

i

�i

u

i

v

T

i

with ⌃ = diag(�i

).

Matlab: [U,S,V] = svd(F);

p�1

u1

andp�1

vT1

are the vertical and horizontal filter.

[Source: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 55 / 58

Page 117: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

How can we tell if a given filter F is indeed separable?

Inspection... this is what we were doing.

Looking at the analytic form of it.

Look at the singular value decomposition (SVD), and if only one

singular value is non-zero, then it is separable

F = U⌃VT =X

i

�i

u

i

v

T

i

with ⌃ = diag(�i

).

Matlab: [U,S,V] = svd(F);

p�1

u1

andp�1

vT1

are the vertical and horizontal filter.

[Source: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 55 / 58

Page 118: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

How can we tell if a given filter F is indeed separable?

Inspection... this is what we were doing.

Looking at the analytic form of it.

Look at the singular value decomposition (SVD), and if only one

singular value is non-zero, then it is separable

F = U⌃VT =X

i

�i

u

i

v

T

i

with ⌃ = diag(�i

).

Matlab: [U,S,V] = svd(F);

p�1

u1

andp�1

vT1

are the vertical and horizontal filter.

[Source: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 55 / 58

Page 119: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Summary – Stu↵ You Should Know

Correlation: Slide a filter across image and compare (via dot product)

Convolution: Flip the filter to the right and down and do correlation

Smooth image with a Gaussian kernel: bigger � means more blurring

Some filters (like Gaussian) are separable: you can filter faster. First apply1D convolution to each row, followed by another 1D conv. to each column

Applying first a Gaussian filter with �1

and then another Gaussian with �2

isthe same as applying one Gaussian filter with � =

p�2

1

+ �2

2

Matlab functions:

imfilter: can do both correlation and convolution

corr2, filter2: correlation, normxcorr2 normalized correlation

conv2: does convolution

fspecial: creates special filters including a Gaussian

Sanja Fidler CSC420: Intro to Image Understanding 56 / 58

Page 120: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Edges

What does blurring take away?

!"#$#%&'( )*!!+,-.(/0102(

!"

.-+&#'(

#"

[Source: S. Lazebnik]

Sanja Fidler CSC420: Intro to Image Understanding 57 / 58

Page 121: Cameras and Imagesfidler/slides/2017/CSC420/lecture2.pdf · Image Transformations As with any function, we can apply operators to an image, e.g.: We’ll talk about special kinds

Next time:

Edge Detection

Sanja Fidler CSC420: Intro to Image Understanding 58 / 58


Recommended