cs 4758/6758: robot learning - cornell university

55
CS 4758/6758: Robot Learning CS 4758/6758: Robot Learning Ashutosh Saxena Spring 2010: Lecture 3. Ashutosh Saxena Slides coutesy: Prof Noah Snavely, Yung-Yu Chung, Frédo Durand, Alexei Efros, William Freeman, Svetlana Lazebnik, Srinivasa Narasimhan, Steve Seitz, Richard Szeliski, and Li Zhang

Upload: others

Post on 05-May-2022

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS 4758/6758: Robot Learning - Cornell University

CS 4758/6758: Robot LearningCS 4758/6758: Robot Learning

Ashutosh Saxena

CS 4758/6758: Robot LearningCS 4758/6758: Robot Learning

Spring 2010: Lecture 3.

Ashutosh Saxena

Slides coutesy: Prof Noah Snavely, Yung-Yu Chung, Frédo Durand, Alexei Efros, William Freeman, Svetlana Lazebnik, Srinivasa Narasimhan, Steve Seitz, Richard Szeliski, and Li Zhang

Page 2: CS 4758/6758: Robot Learning - Cornell University

Ashutosh Saxena

Page 3: CS 4758/6758: Robot Learning - Cornell University

The environmentThe environment

Ashutosh Saxena

Page 4: CS 4758/6758: Robot Learning - Cornell University

Camera as sensorCamera as sensor

� Image and signal processing.

Implementation:

� OpenCV for processing the Image signals.

Ashutosh Saxena

� OpenCV for processing the Image signals.

� Other libraries for processing 1D signals.

Page 5: CS 4758/6758: Robot Learning - Cornell University

What is an image?What is an image?

Ashutosh Saxena

Digital Camera

Source: A. Efros

We get this as the input data

Page 6: CS 4758/6758: Robot Learning - Cornell University

What is an image?What is an image?

� A grid of intensity values

==

255 255 255 255 255 255 255 255 255 255 255 255

255 255 255 255 255 255 255 255 255 255 255 255

255 255 255 20 0 255 255 255 255 255 255 255

255 255 255 75 75 75 255 255 255 255 255 255

255 255 75 95 95 75 255 255 255 255 255 255

255 255 96 127 145 175 255 255 255 255 255 255

Ashutosh Saxena

(common to use one byte per value: 0 = black, 255 = white)

== 255 255 96 127 145 175 255 255 255 255 255 255

255 255 127 145 175 175 175 255 255 255 255 255

255 255 127 145 200 200 175 175 95 255 255 255

255 255 127 145 200 200 175 175 95 47 255 255

255 255 127 145 145 175 127 127 95 47 255 255

255 255 74 127 127 127 95 95 95 47 255 255

255 255 255 74 74 74 74 74 74 255 255 255

255 255 255 255 255 255 255 255 255 255 255 255

255 255 255 255 255 255 255 255 255 255 255 255

Page 7: CS 4758/6758: Robot Learning - Cornell University

� We can think of a (grayscale) image as a function, f, from R2 to R:

◦ f (x,y) gives the intensity at position (x,y)

What is an image?What is an image?

x

f (x, y)

Ashutosh Saxena

◦ A digital image is a discrete (sampled, quantized) version of this function

x

y

snoop

3D view

Page 8: CS 4758/6758: Robot Learning - Cornell University

Image transformationsImage transformations

� As with any function, we can apply operators to an image

Ashutosh Saxena

� We’ll talk about a special kind of operator, convolution (linear filtering)

g (x,y) = f (x,y) + 20 g (x,y) = f (-x,y)

Page 9: CS 4758/6758: Robot Learning - Cornell University

1D signal1D signal

Ashutosh Saxena

255 200 178 100 74 67 71 101 120 180 211 240

Page 10: CS 4758/6758: Robot Learning - Cornell University

Question: Noise reductionQuestion: Noise reduction� Given a camera and a still scene, how can you reduce noise?

Ashutosh Saxena

Take lots of images and average them!

What’s the next best thing? Source: S. Seitz

Page 11: CS 4758/6758: Robot Learning - Cornell University

Image filteringImage filtering

� Modify the pixels in an image based on some function of a local neighborhood of each pixel

5 310 Some function

Ashutosh Saxena

5 14

1 71

5 310

Local image data

7

Modified image data

Some function

Source: L. Zhang

Page 12: CS 4758/6758: Robot Learning - Cornell University

Linear filteringLinear filtering

� One simple version: linear filtering (cross-correlation, convolution)◦ Replace each pixel by a linear combination of its neighbors

� The prescription for the linear combination is

Ashutosh Saxena

� The prescription for the linear combination is called the “kernel” (or “mask”, “filter”)

0.5

0.

5

00

10

0 00

kernel

8

Modified image data

Source: L. Zhang

Local image

data

6 14

1 81

5 310

Page 13: CS 4758/6758: Robot Learning - Cornell University

CrossCross--correlationcorrelation

Let be the image, be the kernel (of

size 2k+1 x 2k+1), and be the output

image

Ashutosh Saxena

This is called a cross-correlation operation:

Page 14: CS 4758/6758: Robot Learning - Cornell University

ConvolutionConvolution

� Same as cross-correlation, except that the kernel is “flipped” (horizontally and vertically)

Ashutosh Saxena

� Convolution / cross-correlation are commutative and associative

This is called a convolution operation:

Page 15: CS 4758/6758: Robot Learning - Cornell University

ConvolutionConvolution

Ashutosh SaxenaAdapted from F. Durand

Page 16: CS 4758/6758: Robot Learning - Cornell University

Mean filteringMean filtering

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

1 1 1

1 1 1

* =

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

Ashutosh Saxena

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

1 1 1

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

Page 17: CS 4758/6758: Robot Learning - Cornell University

Mean Filtering: 1Mean Filtering: 1--DD

One can also apply convolution to 1D signals.

Ashutosh Saxena

F = [0,10, 12, 20, 8, 12, 0]

H = [.25 .5 .25]

G = ?

Page 18: CS 4758/6758: Robot Learning - Cornell University

Linear filters: examplesLinear filters: examples

000

* =

Ashutosh Saxena

000

010

Original Identical image

Source: D. Lowe

* =

Page 19: CS 4758/6758: Robot Learning - Cornell University

Linear filters: examplesLinear filters: examples

000

* =

Ashutosh Saxena

000

001

Original Shifted left

By 1 pixel

Source: D. Lowe

* =

Page 20: CS 4758/6758: Robot Learning - Cornell University

Linear filters: examplesLinear filters: examples

111

111

* =

Ashutosh Saxena

Original

111

111

Blur (with a mean

filter)

Source: D. Lowe

* =

Page 21: CS 4758/6758: Robot Learning - Cornell University

Linear filters: examplesLinear filters: examples

111

111

020

000

- =*

Ashutosh Saxena

Original

111

111

000

020 -

Sharpening

filter

(accentuates

edges)

Source: D. Lowe

=*

Page 22: CS 4758/6758: Robot Learning - Cornell University

Gaussian KernelGaussian Kernel

Ashutosh SaxenaSource: C. Rasmussen

Page 23: CS 4758/6758: Robot Learning - Cornell University

Mean vs. Gaussian filteringMean vs. Gaussian filtering

Ashutosh Saxena

Page 24: CS 4758/6758: Robot Learning - Cornell University

Gaussian noiseGaussian noise

Ashutosh Saxena

= 1 pixel = 2 pixels = 5 pixels

Smoothing with larger standard deviations suppresses noise, but

also blurs the image

Page 25: CS 4758/6758: Robot Learning - Cornell University

Outliers noise Outliers noise –– Gaussian blurGaussian blur

Ashutosh Saxena

= 1 pixel = 2 pixels = 5 pixels

• What’s wrong with the results?

p = 10%

Page 26: CS 4758/6758: Robot Learning - Cornell University

Alternative idea: Median filteringAlternative idea: Median filtering

• A median filter operates over a window by selecting the median intensity in the window

Ashutosh Saxena

• Is median filtering linear?Source: K. Grauman

Page 27: CS 4758/6758: Robot Learning - Cornell University

Median filterMedian filter

• What advantage does median filtering have over Gaussian filtering?

Ashutosh SaxenaSource: K. Grauman

Page 28: CS 4758/6758: Robot Learning - Cornell University

Salt & pepper noise Salt & pepper noise –– median filteringmedian filtering

Ashutosh Saxena

= 1 pixel = 2 pixels = 5 pixels

3x3 window 5x5 window 7x7 window

p = 10%

Page 29: CS 4758/6758: Robot Learning - Cornell University

Questions?Questions?

Ashutosh Saxena

Page 30: CS 4758/6758: Robot Learning - Cornell University

Edge DetectionEdge Detection

Ashutosh Saxena

Page 31: CS 4758/6758: Robot Learning - Cornell University

Edge detectionEdge detection

• Convert a 2D image into a set of curves

– Extracts salient features of the scene

– More compact than pixels

Page 32: CS 4758/6758: Robot Learning - Cornell University

Characterizing edgesCharacterizing edges

• An edge is a place of rapid change in the image intensity function

image

intensity function

(along horizontal scanline) first derivative

Ashutosh Saxena

edges correspond to

extrema of derivativeSource: L. Lazebnik

Page 33: CS 4758/6758: Robot Learning - Cornell University

Effects of noiseEffects of noise

Ashutosh Saxena

Where is the edge?Source: S. Seitz

Noisy input image

Page 34: CS 4758/6758: Robot Learning - Cornell University

Solution: smooth firstSolution: smooth first

f

h

Ashutosh Saxena

f * h

Source: S. Seitz

To find edges, look for peaks in

Page 35: CS 4758/6758: Robot Learning - Cornell University

• Differentiation is convolution, and convolution is associative:

• This saves us one operation:

Associative property of convolutionAssociative property of convolution

f

Ashutosh Saxena

f

Source: S. Seitz

Page 36: CS 4758/6758: Robot Learning - Cornell University

2D edge detection filters2D edge detection filters

Ashutosh Saxena

Gaussianderivative of Gaussian (x)

Page 37: CS 4758/6758: Robot Learning - Cornell University

Derivative of Gaussian filterDerivative of Gaussian filter

Ashutosh Saxena

x-direction y-direction

Page 38: CS 4758/6758: Robot Learning - Cornell University

The Sobel operatorThe Sobel operator

� Common approximation of derivative of Gaussian

-1 0 1

-2 0 2

1 2 1

0 0 0

-1 0 1 -1 -2 -1

Page 39: CS 4758/6758: Robot Learning - Cornell University

Sobel operator: exampleSobel operator: example

Ashutosh SaxenaSource: Wikipedia

Page 40: CS 4758/6758: Robot Learning - Cornell University

Questions?Questions?

Ashutosh Saxena

Page 41: CS 4758/6758: Robot Learning - Cornell University

Finding ObjectsFinding Objects

� Background subtraction

Ashutosh Saxena

Page 42: CS 4758/6758: Robot Learning - Cornell University

Feature extraction: Corners and blobsFeature extraction: Corners and blobs

Ashutosh Saxena

Page 43: CS 4758/6758: Robot Learning - Cornell University

Desirable properties in the featuresDesirable properties in the features

Distinctiveness:

◦ can differentiate a large database of objects

Efficiency

◦ real-time performance achievable

Ashutosh Saxena

◦ real-time performance achievable

Page 44: CS 4758/6758: Robot Learning - Cornell University

Example of featuresExample of features

A laundry list:

� Corner / edge detectors

� SIFT features

Ashutosh Saxena

� SIFT features

� Output of various filters…

Page 45: CS 4758/6758: Robot Learning - Cornell University

Feature MatchingFeature Matching

Ashutosh Saxena

Page 46: CS 4758/6758: Robot Learning - Cornell University

Feature MatchingFeature Matching

Ashutosh Saxena

Page 47: CS 4758/6758: Robot Learning - Cornell University

Metric for similarity?Metric for similarity?

� Vector xi and xj .

� What is the distance between them?

Ashutosh Saxena

Page 48: CS 4758/6758: Robot Learning - Cornell University

Matching using distance between the Matching using distance between the featuresfeatures

Find features that are invariant to transformations

◦ geometric invariance: translation, rotation, scale

◦ photometric invariance: brightness, exposure, …

Ashutosh Saxena

Feature Descriptors

Page 49: CS 4758/6758: Robot Learning - Cornell University

Object recognition (David Lowe)Object recognition (David Lowe)

Ashutosh Saxena

Page 50: CS 4758/6758: Robot Learning - Cornell University

Image matchingImage matching

Ashutosh Saxena

by Diva Sian

by swashford

Page 51: CS 4758/6758: Robot Learning - Cornell University

Harder caseHarder case

Ashutosh Saxena

by Diva Sian by scgbt

Page 52: CS 4758/6758: Robot Learning - Cornell University

Harder still?Harder still?

Ashutosh Saxena

NASA Mars Rover images

Page 53: CS 4758/6758: Robot Learning - Cornell University

How to match features?How to match features?

� Robustness?

Machine Learning to the rescue.

Supervised Learning: next lecture.

Ashutosh Saxena

Supervised Learning: next lecture.

Page 54: CS 4758/6758: Robot Learning - Cornell University

ProjectsProjects

� Project proposals due Feb 15.

◦ Brief description of the projects on Thursday lecture.

◦ Choose a Topic and a Robot.

Ashutosh Saxena

Choose a Topic and a Robot.

� Good time to setup a meeting with the instructor next week.

Page 55: CS 4758/6758: Robot Learning - Cornell University

Questions?Questions?

Ashutosh Saxena