Edge Detection Lecture 6 Edge Detection Convert a

  • Slides: 35
Download presentation
Edge Detection Lecture #6

Edge Detection Lecture #6

Edge Detection • Convert a 2 D image into a set of curves –

Edge Detection • Convert a 2 D image into a set of curves – Extracts salient features of the scene – More compact than pixels

Origin of Edges surface normal discontinuity depth discontinuity surface color discontinuity illumination discontinuity •

Origin of Edges surface normal discontinuity depth discontinuity surface color discontinuity illumination discontinuity • Edges are caused by a variety of factors

Edge Types Step Edges Roof Edge Line Edges

Edge Types Step Edges Roof Edge Line Edges

Real Edges Noisy and Discrete! We want an Edge Operator that produces: – Edge

Real Edges Noisy and Discrete! We want an Edge Operator that produces: – Edge Magnitude – Edge Orientation – High Detection Rate and Good Localization

Gradient • Gradient equation: • Represents direction of most rapid change in intensity •

Gradient • Gradient equation: • Represents direction of most rapid change in intensity • Gradient direction: • The edge strength is given by the gradient magnitude

Theory of Edge Detection Ideal edge Unit step function: Image intensity (brightness):

Theory of Edge Detection Ideal edge Unit step function: Image intensity (brightness):

Theory of Edge Detection • Image intensity (brightness): • Partial derivatives (gradients): • Squared

Theory of Edge Detection • Image intensity (brightness): • Partial derivatives (gradients): • Squared gradient: Edge Magnitude: Edge Orientation: (normal of the edge) Rotationally symmetric, non-linear operator

Theory of Edge Detection • Image intensity (brightness): • Partial derivatives (gradients): • Laplacian:

Theory of Edge Detection • Image intensity (brightness): • Partial derivatives (gradients): • Laplacian: Rotationally symmetric, linear operator zero-crossing

Discrete Edge Operators • How can we differentiate a discrete image? Finite difference approximations:

Discrete Edge Operators • How can we differentiate a discrete image? Finite difference approximations: Convolution masks :

Discrete Edge Operators • Second order partial derivatives: • Laplacian : Convolution masks :

Discrete Edge Operators • Second order partial derivatives: • Laplacian : Convolution masks : or (more accurate)

The Sobel Operators • Better approximations of the gradients exist – The Sobel operators

The Sobel Operators • Better approximations of the gradients exist – The Sobel operators below are commonly used -1 0 1 1 2 1 -2 0 0 0 -1 0 1 -1 -2 -1

Comparing Edge Operators Good Localization Noise Sensitive Poor Detection Gradient: Roberts (2 x 2):

Comparing Edge Operators Good Localization Noise Sensitive Poor Detection Gradient: Roberts (2 x 2): 0 1 1 0 -1 0 0 -1 Sobel (3 x 3): -1 0 1 1 -1 0 0 0 -1 0 1 -1 -1 1 Sobel (5 x 5): -1 -2 0 2 1 1 2 3 2 1 -2 -3 0 3 2 2 3 5 3 2 -3 -5 0 5 3 0 0 0 -2 -3 0 3 2 -2 -3 -5 -3 -2 -1 -2 0 2 1 -1 -2 -3 -2 -1 Poor Localization Less Noise Sensitive Good Detection

Effects of Noise • Consider a single row or column of the image –

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? ?

Solution: Smooth First Where is the edge? Look for peaks in

Solution: Smooth First Where is the edge? Look for peaks in

Derivative Theorem of Convolution …saves us one operation.

Derivative Theorem of Convolution …saves us one operation.

Laplacian of Gaussian (Lo. G) Laplacian of Gaussian operator Where is the edge? Zero-crossings

Laplacian of Gaussian (Lo. G) Laplacian of Gaussian operator Where is the edge? Zero-crossings of bottom graph !

2 D Gaussian Edge Operators Gaussian Derivative of Gaussian (Do. G) Laplacian of Gaussian

2 D Gaussian Edge Operators Gaussian Derivative of Gaussian (Do. G) Laplacian of Gaussian Mexican Hat (Sombrero) • is the Laplacian operator:

Canny Edge Operator • Smooth image I with 2 D Gaussian: • Find local

Canny Edge Operator • Smooth image I with 2 D Gaussian: • Find local edge normal directions for each pixel • Compute edge magnitudes • Locate edges by finding zero-crossings along the edge normal directions (non-maximum suppression)

Non-maximum Suppression • Check if pixel is local maximum along gradient direction – requires

Non-maximum Suppression • Check if pixel is local maximum along gradient direction – requires checking interpolated pixels p and r

The Canny Edge Detector original image (Lena)

The Canny Edge Detector original image (Lena)

The Canny Edge Detector magnitude of the gradient

The Canny Edge Detector magnitude of the gradient

The Canny Edge Detector After non-maximum suppression

The Canny Edge Detector After non-maximum suppression

Canny Edge Operator original Canny with • The choice of – large – small

Canny Edge Operator original Canny with • The choice of – large – small Canny with depends on desired behavior detects large scale edges detects fine features

Difference of Gaussians (Do. G) • Laplacian of Gaussian can be approximated by the

Difference of Gaussians (Do. G) • Laplacian of Gaussian can be approximated by the difference between two different Gaussians

Do. G Edge Detection (a) (b)-(a)

Do. G Edge Detection (a) (b)-(a)

Gaussian – Image filter Fourier Transform Gaussian delta function

Gaussian – Image filter Fourier Transform Gaussian delta function

Unsharp Masking – = +a =

Unsharp Masking – = +a =

MATLAB demo g = fspecial('gaussian', 15, 2); imagesc(g) surfl(g) gclown = conv 2(clown, g,

MATLAB demo g = fspecial('gaussian', 15, 2); imagesc(g) surfl(g) gclown = conv 2(clown, g, 'same'); imagesc(conv 2(clown, [-1 1], 'same')); imagesc(conv 2(gclown, [-1 1], 'same')); dx = conv 2(g, [-1 1], 'same'); imagesc(conv 2(clown, dx, 'same'); lg = fspecial('log', 15, 2); lclown = conv 2(clown, lg, 'same'); imagesc(lclown) imagesc(clown +. 2*lclown)

Edge Thresholding • Standard Thresholding: • Can only select “strong” edges. • Does not

Edge Thresholding • Standard Thresholding: • Can only select “strong” edges. • Does not guarantee “continuity”. • Hysteresis based Thresholding (use two thresholds) Example: For “maybe” edges, decide on the edge if neighboring pixel is a strong edge.

Edge Relaxation • Parallel – Iterative method to adjust edge values on the basis

Edge Relaxation • Parallel – Iterative method to adjust edge values on the basis of neighboring edges. a f No Edge e b g Edge to be updated Edge c • Vertex Types: (0) h (1)

Edge Relaxation • Vertex Types (continued): (2) (3)

Edge Relaxation • Vertex Types (continued): (2) (3)

Edge Relaxation Algorithm • Action Table: Edge Type Decrement Increment Leave as is 0

Edge Relaxation Algorithm • Action Table: Edge Type Decrement Increment Leave as is 0 -0 1 -1 0 -2 0 -3 1 -2 1 -3 0 -1 2 -2 2 -3 3 -3 • Algorithm: Step 0: Compute Initial Confidence of each edge e: Step 1: Initialize Step 2: Compute Edge Type of each edge e Step 3: Modify confidence based on and Edge Type Step 4: Test to see if all have CONVERGED to either 1 or 0. Else go to Step 2.

Edge Relaxation

Edge Relaxation

Next Class • Boundary Detection and Hough Transform

Next Class • Boundary Detection and Hough Transform