lecture 7: edge detection - university of...

79
ME5286 – Lecture 6 #1 Lecture 7: Edge Detection Saad J Bedros [email protected]

Upload: others

Post on 03-May-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#1

Lecture 7: Edge Detection

Saad J [email protected]

Page 2: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#2

Review From Last Lecture

• Definition of an Edge• First Order Derivative Approximation as

Edge Detector

Page 3: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#3

This Lecture

• Examples of Edge Detection with first order derivative approximation

• Edge Detection with Second order derivative

• Combining Smoothing and Edge Detection with Laplacian of Gaussian

Page 4: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#4

Summary: Edge Definition• Edge is a boundary between two regions with relatively distinct gray level

properties. • Edges are pixels where the brightness function changes abruptly. • Edge detectors are a collection of very important local image pre-

processing methods used to locate (sharp) changes in the intensity function.

Page 5: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Criteria for Optimal Edge Detection

• (1) Good detection– Minimize the probability of false positives (i.e., spurious edges).– Minimize the probability of false negatives (i.e., missing real

edges).

• (2) Good localization– Detected edges must be as close as possible to the true edges.

• (3) Single response– Minimize the number of local maxima around the true edge.

Page 6: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Edge Detection Using Derivatives

• Often, points that lie on an edge are detected by:

(1) Detecting the local maxima or minima of the first derivative.

(2) Detecting the zero-crossingsof the second derivative. 2nd derivative

1st derivative

Page 7: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Edge Detection Using First Derivative

sensitive to vertical edges!

sensitive to horizontal edges!

Page 8: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

• We can implement and using the following masks:

(x+1/2,y)

(x,y+1/2) **

good approximationat (x+1/2,y)

good approximationat (x,y+1/2)

Edge Detection Using First Derivative

Page 9: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Approximation of First Derivative ( Gradient )

• Consider the arrangement of pixels about the pixel (i, j):

• The partial derivatives can be computed by:

• The constant c implies the emphasis given to pixels closer to the center of the mask.

3 x 3 neighborhood:

Page 10: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Prewitt Operator

• the Prewitt operator:

Page 11: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Sobel Operator

• the Sobel operator:

Page 12: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#12

Robert Edge Detection• The Roberts edge detector

• This approximation can be implemented by the following masks:

Note: Mx and My are approximations at (i + 1/2, j + 1/2)

Page 13: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#13

Roberts Edge Detector

There are two forms of the Roberts Edge Detector:

The second form of the equation is often used in practice due to its computational efficiency

Page 14: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#14

Roberts Edge Detector• A simple approximation to the first

derivative • Marks edge points only; it does not return

any information about the edge orientation

• Simplest of the edge detection operators and will work best with binary images

Page 15: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Example

Idxd

Idyd

Page 16: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#16

Edge Detection Using Derivative• Image derivatives:

11* II x

11

*II y

Image I

Page 17: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#17

Edge Detection Using the Gradient• Example – cont.:

22

I

dydI

dxd

Page 18: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#18

Edge Detection Using the Gradient• Example – cont.:

100 Threshold

Page 19: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#19

Derivatives and Noise• Derivatives are strongly affected by noise

– obvious reason: image noise results in pixels that look very different from their neighbors

– The larger the noise - the stronger the response• What is to be done?

– Neighboring pixels look alike– Pixel along an edge look alike– Image smoothing should help – Force pixels different to their neighbors (possibly noise) to

look like neighbors

Page 20: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#20

Derivatives and Noise

Increasing noise

– Need to perform image smoothing as a preliminary step– Generally – use Gaussian smoothing

Page 21: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#21

Edge Detection & Image Noisei.i.d ),0(~)( )()(ˆ)( NxNxNxIxI

)()('ˆ

))1( - )1(())1(ˆ)1(ˆ(

))1()1(ˆ( - )1()1(ˆ)('

xNxI d

xNxNxIxI

xNxIxNxIxI

))(( xNE d 0

Taking differences:

Output noise:

))(( 2 xNE d ))1()1(2)1()1(( 22 xNxNxNxNE222 20

Increases noise !!

Page 22: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#22

Effects of noise• Consider a single row or column of the image

– Plotting intensity as a function of position gives a signal

• Where is the edge?

Page 23: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#23

Noise in Edge Detection• Practical issues:– Differential masks act as high-pass filters – tend to amplify noise.– Reduce the effects of noise - first smooth with a low-pass filter.

1) The noise suppression-localization tradeoff– a larger filter reduces noise, but worsens localization (i.e., it

adds uncertainty to the location of the edge) and vice-versa.

Page 24: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#24• Where is the edge?

Solution: smooth first

Page 25: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#25

Derivative theorem of convolution

• This saves us one operation:

Page 26: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

11 0.0030 0.0133 0.0219 0.0133 0.00300.0133 0.0596 0.0983 0.0596 0.01330.0219 0.0983 0.1621 0.0983 0.02190.0133 0.0596 0.0983 0.0596 0.01330.0030 0.0133 0.0219 0.0133 0.0030

)()( hgIhgI

Derivative of Gaussian filters

Page 27: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Derivative of Gaussian filters

x-direction y-direction

Source: L. Lazebnik

Page 28: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Smoothing with a GaussianRecall: parameter σ is the “scale” / “width” / “spread” of the Gaussian kernel, and controls the amount of smoothing.

Page 29: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Effect of σ on derivatives

The apparent structures differ depending on Gaussian’s scale parameter.

Larger values: larger scale edges detectedSmaller values: finer features detected

σ = 1 pixel σ = 3 pixels

Page 30: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Edge Detection Steps Using Gradient

(i.e., sqrt is costly!)

Page 31: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Edge Direction Implementation• Typically quantize the gradient orientation to a

fixed number of orientations• You can identify the edges based on

magnitude and direction

How Many Directions or Levels ?

Page 32: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#32

Page 33: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Isotropy#33

Page 34: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Isotropic property of gradient magnitude

• The magnitude of the gradient detects edges in all directions.

22d dI Idx dy

Idxd I

dyd

Page 35: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#35

Edge Detection Using the Gradient• Isotropic property of gradient magnitude:

– The magnitude of gradient is an isotropic operator (it detects edges in any direction !!)

Page 36: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Anisotropic Filtering (i.e., edge preserving smoothing)

• Symmetric Gaussian smoothing tends to blur out edges rather aggressively.

• An “oriented” smoothing operator would work better:(i) Smooth aggressively perpendicular to the gradient(ii) Smooth little along the gradient

Page 37: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Anisotropic filtering - Example

result using anisotropic filtering

Page 38: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#38

Page 39: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#39

Edge Detection Using the 2nd Derivative• Edge points can be detected by finding the zero-

crossings of the second derivative.

• There are two approaches that uses the second derivative to identify the edge presence• Smoothing then apply Gradient• Combine smoothing and Gradient Opertations

Page 40: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Edge Detection Using SecondDerivative

• Approximate finding maxima/minima of gradient magnitude by finding places where:

• Can’t always find discrete pixels where the second derivative is zero – look for zero-crossing instead.

Page 41: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#41

Edge Detection Using Second Derivative• Computing the 2nd derivative:

– This approximation is centered about x + 1– By replacing x + 1 by x we obtain:

Page 42: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Image Derivatives

• 1st order

• 2nd order

Page 43: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Edge Detection Using Second Derivative (cont’d)

Page 44: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#44

Edge Detection Using Second Derivative (cont’d)

• Computing the 2nd derivative – cont.– Examples using the edge models:

Page 45: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Edge Detection Using Second Derivative (cont’d)

(upward) step edge

(downward) step edge

ramp edge

roof edge

Page 46: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Edge Detection Using Second Derivative (cont’d)

• Four cases of zero-crossings:

{+,-}, {+,0,-},{-,+}, {-,0,+}

• Slope of zero-crossing {a, -b} is: |a+b|.

• To detect “strong” zero-crossing, threshold the slope.

Page 47: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Second Derivative in 2D: Laplacian

Page 48: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Second Derivative in 2D: Laplacian

Page 49: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Variations of Laplacian

Page 50: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Laplacian - Example

detect zero-crossings

Page 51: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Properties of Laplacian

• It is cheaper to implement than the gradient (i.e., one mask only).

• It does not provide information about edge direction.

• It is more sensitive to noise (i.e., differentiates twice).

• It is an isotropic operator ( equal weights in all directions )

Page 52: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Noise Effect on Derivates

Where is the edge??

Page 53: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Solution: smooth first

Page 54: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Effect of Smoothing on Derivatives (cont’d)

Page 55: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Combine Smoothing with Differentiation

(i.e., saves one operation)

Page 56: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Laplacian of GaussianConsider

Laplacian of Gaussianoperator

Where is the edge? Zero-crossings of bottom graphSlide credit: Steve Seitz

Page 57: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

2D edge detection filters

• is the Laplacian operator:

Laplacian of Gaussian

Gaussian derivative of Gaussian

Slide credit: Steve Seitz

Page 58: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Laplacian of Gaussian (LoG)(Marr-Hildreth operator)

• To reduce the noise effect, the image is first smoothed. • When the filter chosen is a Gaussian, we call it the LoG

edge detector.

• It can be shown that:

σ controls smoothing

2σ2

(inverted LoG)

Page 59: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Laplacian of Gaussian (LoG)(Marr-Hildreth operator)

• The 2-D Laplacian of Gaussian (LoG) function centered on zero and with Gaussian standard deviation has the form:

where σ is the standard deviation

• The amount of smoothing can be controlled by varying the value of the standard deviation.

Page 60: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Laplacian of Gaussian (LoG) -Example

filtering zero-crossings

(inverted LoG)(inverted LoG)

Page 61: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Decomposition of LoG• It can be shown than LoG can be written as

follows:

• 2D LoG convolution can be implemented using 4, 1D convolutions.

2 ( , )g x y

2 ( , )* ( , )g x y I x y

Page 62: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#62

Edge Detection Using the 2nd Derivative• Separability

Image

gxx(x) g(x)

gyy(y) g(y)

+ gI 2*

Image g(x) g(y) + gI

Gaussian Filtering

Laplacian-of-Gaussian Filtering

Page 63: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#63

Edge Detection Using the 2nd Derivative• Separability

– Gaussian:• A 2-D Gaussian can be separated into two 1-D Gaussians• Perform 2 convolutions with 1-D Gaussians

),(*),(),( yxgyxIyxh

)(*)(*),(),( 21 ygxgyxIyxh

n2 multiplications per pixel

2n multiplications per pixel

011.13.6.16.13.011.1 g

011.13.6.16.13.011.

2g

Page 64: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Decomposition of LoG (cont’d)

Steps

Page 65: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#65

Edge Detection Using LOG• Marr-Hildteth (LOG) Algorithm:

– Compute LoG• Use one 2D filter:• Use four 1D filters:

– Find zero-crossings from each row and column– Find slope of zero-crossings– Apply threshold to slope and mark edges

),(2 yxg)(),(),(),( ygygxgxg yyxx

Page 66: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#66

Laplacian of Gaussian (LoG) - Example• The Laplacian-of-Gaussian (LOG) – cont.

GI 2* I

)(*I of crossings Zero 2G

Page 67: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#67

Laplacian of Gaussian (LoG) - Example• The Laplacian-of-Gaussian (LOG) – cont.

1

6

3

Page 68: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Difference of Gaussians (DoG)• The Laplacian of Gaussian can be approximated by the

difference between two Gaussian functions:

approximationactual LoG

Page 69: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Difference of Gaussians (DoG) (cont’d)

(a) (b) (b)‐(a)

Page 70: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#70

Gradient vs LoG (cont’d)• Disadvantage of LOG edge detection:

– Does not handle corners well

Page 71: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Gradient vs LoG• Gradient works well when the image contains sharp

intensity transitions and low noise.• Zero-crossings of LOG offer better localization, especially

when the edges are not very sharp.step edge

ramp edge

Page 72: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Practical Issues

• Noise suppression-localization tradeoff.– Smoothing depends on mask size (e.g., depends

on σ for Gaussian filters).– Larger mask sizes reduce noise, but worsen

localization (i.e., add uncertainty to the location of the edge) and vice versa.

larger masksmaller mask

Page 73: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Choice of Threshold• Trade off of threshold value.

gradient magnitude

low threshold high threshold

Page 74: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Standard thresholding• Standard thresholding:

- Can only select “strong” edges.- Does not guarantee “continuity”.

gradient magnitude low threshold high threshold

Page 75: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Hysteresis thresholding

• Hysteresis thresholding uses two thresholds:

• For “maybe” edges, decide on the edge if neighboringpixel is a strong edge.

- low threshold tl- high threshold th (usually, th = 2tl)

tltl

th

th

Page 76: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

Hysteresis Thresholding Example#76

Page 77: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#77

Edge Detection Review

• Edge detection operators are based on the idea that edge information in an image is found by looking at the relationship a pixel has with its neighbors

• If a pixel's gray level value is similar to those around it, there is probably not an edge at that point

Page 78: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#78

Edge Detection Review

• Edge detection operators are often implemented with convolution masks and most are based on discrete approximations to differential operators

• Differential operations measure the rate of change in a function, in this case, the image brightness function

Page 79: Lecture 7: Edge Detection - University of Minnesotadept.me.umn.edu/courses/me5286/vision/VisionNotes/2017/...ME5286 – Lecture 6 #4 Summary: Edge Definition • Edge is a boundary

ME5286 – Lecture 6

#79

Edge Detection Review• Preprocessing of image is required to eliminate or

at least minimize noise effects• There is tradeoff between sensitivity and accuracy

in edge detection • The parameters that we can set so that edge

detector is sensitive include the size of the edge detection mask and the value of the gray level threshold

• A larger mask or a higher gray level threshold will tend to reduce noise effects, but may result in a loss of valid edge points