edge detection and corner detection

40
CSE 152A, Winter 2021 Introduction to Computer Vision I Edge Detection and Corner Detection Introduction to Computer Vision I CSE 152A Lecture 6

Upload: others

Post on 07-Jan-2022

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Edge Detection and Corner Detection

Introduction to Computer Vision ICSE 152ALecture 6

Page 2: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Announcements• Assignment 1 is due Jan 27, 11:59 PM• Quiz 1 is Jan 29• Assignment 1 will be released Jan 27

– Due Feb 10, 11:59 PM• Reading:

– Szeliski• Sections 7.2.1 and 7.1.1

Page 3: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Image Segmentation and Edges• Image Segmentation is the process of dividing an image into

connected regions such that pixels within a region share certain characteristics (color, texture , brightness, etc.)

• Boundaries or edges divide segmented regions.

[From Berkeley Segmentation Dataset] 13 Regions

Page 4: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Image Segmentation

[From Berkeley Segmentation Dataset]

Page 5: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Related Topics: Semantic and Instance Segmentation

Page 6: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Edges in Natural Images

Source: Photografr.com

Page 7: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

• Depth discontinuity• Surface orientation discontinuity• Illumination discontinuity (e.g.,

shadow)• Specular reflection of other

discontinuity• Reflectance discontinuity (i.e.,

change in surface material properties)

What Causes an Edge?

Source: Photografr.com

Page 8: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Noisy 1D Step Edge• Derivative is high everywhere.• Must smooth before taking gradient.

Page 9: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Edge is Where Change Occurs: 1-D• Change is measured by derivative in 1D

Smoothed Edge

First Derivative

Second Derivative

Ideal Edge

• Biggest change, first derivative has maximum magnitude• Or second derivative is zero

Page 10: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Numerical Derivatives of Sampled Signalf(x)

xX0 X0+hX0-h

Take Taylor series expansion of f(x) about x0f(x) = f(x0)+f’(x0)(x-x0) + ½ f’’(x0)(x-x0)2 + …

Consider samples taken at increments of h and first two terms of the expansion, we have

f(x0+h) = f(x0)+f’(x0)h+ ½ f’’(x0)h2

f(x0-h) = f(x0)-f’(x0)h+ ½ f’’(x0)h2

Subtracting and adding f(x0+h) and f(x0-h) respectively yields

20

0

0

)()(2)()(''

2)()(

)('

00

00

hhxfxfhxf

xf

hhxfhxf

xf

−+−+=

−−+= Convolve with

First Derivative: [-1/2h 0 1/2h]Second Derivative: [1/h2 -2/h2 1/h2]

Page 11: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Numerical Derivatives

• With images, units of h is pixels, so h=1– First derivative: [-1/2 0 1/2]– Second derivative: [1 -2 1]

• When computing derivatives in the x and y directions, use these convolution kernels:

Convolution kernelFirst Derivative: [-1/2h 0 1/2h]

Second Derivative: [1/h2 -2/h2 1/h2]

𝑑𝑑𝑑𝑑𝑑𝑑

=−1/2

01/2

𝑑𝑑𝑑𝑑𝑑𝑑

= −1/2 0 1/2

Page 12: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Implementing 1D Edge Detection

x

τ

1. Filter out noise: convolve with Gaussian2. Take a derivative: convolve with [1 0 -1]

We can combine steps 1 and 23. Find the peaks of |df/dx|

Two issues:• Should be a local maximum of |df/dx|• Should be greater than a threshold: |df/dx| > τ

Page 13: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

2D Edge Detection1. Filter out noise

– Use a 2D Gaussian Filter.2. Take a derivative

– Compute the magnitude of the gradient:

Page 14: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Finding derivatives

x

y

Is this dI/dx or dI/dy?

Page 15: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

There are three major issues:1. The gradient magnitude at different scales is different;

which scale should we choose?2. The gradient magnitude is large along a thick trail; how

do we identify the significant points?3. How do we link the relevant points up into curves?

σ = 1 σ = 2

Page 16: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

There is ALWAYS a tradeoff between smoothing and good edge localization!

Image with Edge (No Noise) Edge Location

Image + Noise Derivatives detect edge and noise

Smoothed derivative removes noise, but blurs edge

Page 17: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

The scale of the smoothing filter affects derivative estimates

1 pixel 3 pixels 7 pixels

Page 18: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Corner Detection

Page 19: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Motivation: feature matching• Panorama stitching

– We have two images – how do we combine them?

Page 20: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Motivation: feature matching

Step 1: extract featuresStep 2: match features

• Panorama stitching– We have two images – how do we combine them?

Page 21: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Motivation: feature matching

Step 1: Extract features in each imageStep 2: Match features across imagesStep 3: Align images and determine a transformation

• Panorama stitching– We have two images – how do we combine them?

Page 22: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Image matching

by swashfordby Diva Sian

Page 23: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Harder case

by Diva Sian by scgbt

Page 24: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Harder still?

NASA Mars Rover images

Page 25: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

NASA Mars Rover imageswith SIFT feature matchesFigure by Noah Snavely

Answer below (look for tiny colored squares…)

Page 26: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Corners contain more info than lines• A point on a line is hard to match

Image 1 Image 2

Page 27: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Corners contain more info than lines• A corner is easier to match

Image 1 Image 2

Page 28: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Detection of corner-like features• Corner

– A rapid change of direction in a curve– A highly effective feature

• Distinctive• Reasonably invariant to viewpoint

Page 29: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Corners

Page 30: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Detection of corner-like features• Examine a small window over an image

FlatCornerEdge

The wiggly arrows indicate graphically a directional response in the detector as it moves in the three areas shown

Page 31: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Detection of corner-like features

Intuition:

• Right at corner, gradient is ill-defined.

• Near corner, gradient has two different values.

Page 32: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Detection of corner-like features• For each window location, compute the

spatial gradient matrix

where fx is the gradient in the x-direction and fyis the gradient in the y-direction

• Then, compute eigenvalues of spatial gradient matrix

Page 33: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Eigenvalues of spatial gradient matrix

Page 34: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Detection of corner-like features• Shi-Tomasi corner detector

– Run a small window over an image and compute spatial gradient matrix M

– Compute the minor eigenvalue of M to compute measurement image R

– Apply nonmaximal suppression to the measurement image R

• Prevents corners from being too close to each other– Threshold resulting image R using global

threshold T• Corner at coordinates corresponding to R > T

Page 35: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Corner Detection Sample Results

Threshold=25,000 Threshold=10,000

Threshold=5,000

Page 36: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Corner Detector: Workflow

Slide credit: http://vims.cis.udel.edu/~chandra/

Page 37: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Corner Detector: Workflow

Compute corner response R(x,y)

Slide credit: http://vims.cis.udel.edu/~chandra/

Page 38: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Corner Detector: Workflow

Take only the points of local maxima of R(x,y) and threshold

Slide credit: http://vims.cis.udel.edu/~chandra/

Page 39: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Corner Detector: Workflow

Slide credit: http://vims.cis.udel.edu/~chandra/

Page 40: Edge Detection and Corner Detection

CSE 152A, Winter 2021 Introduction to Computer Vision I

Next Lecture• Feature extraction• Reading:

– Szeliski• Sections 3.5.3 and 7.1.2