13
1 Image Processing Edge Detection • Edge detection masks • Gradient Detectors • Second Derivative - Laplace detectors • Edge Linking • Hough Transform Image Processing Computer Vision Low Level High Level Image Processing - Computer Vision representation, compression,transmission image enhancement edge/feature finding image "understanding" UFO - Unidentified Flying Object Origin of Edges Edges are caused by a variety of factors depth discontinuity surface color discontinuity illumination discontinuity surface normal discontinuity

UFO - Unidentified Flying Object Origin of Edges · UFO - Unidentified Flying Object Origin of Edges Edges are caused by a variety of factors depth discontinuity ... Edge detector

  • Upload
    tranque

  • View
    245

  • Download
    1

Embed Size (px)

Citation preview

Page 1: UFO - Unidentified Flying Object Origin of Edges · UFO - Unidentified Flying Object Origin of Edges Edges are caused by a variety of factors depth discontinuity ... Edge detector

1

Image Processing

Edge Detection

• Edge detection masks

• Gradient Detectors

• Second Derivative - Laplace detectors

• Edge Linking

• Hough Transform

Image Processing

Computer Vision

Low Level

High Level

Image Processing - Computer Vision

representation,compression,transmission

image enhancement

edge/feature finding

image "understanding"

UFO - Unidentified Flying Object Origin of Edges

Edges are caused by a variety of factors

depth discontinuity

surface color discontinuity

illumination discontinuity

surface normal discontinuity

Page 2: UFO - Unidentified Flying Object Origin of Edges · UFO - Unidentified Flying Object Origin of Edges Edges are caused by a variety of factors depth discontinuity ... Edge detector

2

Edge detection

How can you tell that a pixel is on an edge?

Profiles of image intensity edges

gray

val

ue

xedge edge

Step Edge

gray

val

ue

xedge edge

Line Edge

Edge detection

1. Detection of short linear edge segments (edgels)

2. Aggregation of edgels into extended edges

Edge Detection by Differentiation

gray

val

ue

x

1D image f(x)

1st derivative f'(x)

threshold|f'(x)| - threshold

Pixels that passed the threshold are

Edge Pixels

Page 3: UFO - Unidentified Flying Object Origin of Edges · UFO - Unidentified Flying Object Origin of Edges Edges are caused by a variety of factors depth discontinuity ... Edge detector

3

Image gradientThe gradient of an image:

The gradient points in the direction of most rapid change in intensity

The gradient direction is given by:

The edge strength is given by the gradient magnitude

The discrete gradientHow can we differentiate a digital image f[x,y]?

• Option 1: reconstruct a continuous image, then take gradient• Option 2: take discrete derivative (finite difference)

How would you implement this as a convolution?

Effects of noiseConsider a single row or column of the image

• Plotting intensity as a function of position gives a signal

Where is the edge?Where is the edge?

Solution: smooth first

Look for peaks in

Page 4: UFO - Unidentified Flying Object Origin of Edges · UFO - Unidentified Flying Object Origin of Edges Edges are caused by a variety of factors depth discontinuity ... Edge detector

4

Derivative theorem of convolution

This saves us one operation:

Laplacian of Gaussian

Consider

Laplacian of Gaussianoperator

Where is the edge? zero crossing

2D edge detection filters

is the Laplacian operator:

Laplacian of Gaussian

Gaussian derivative of Gaussian

Discrete derivativesThe Sobel operators below are very commonly used

• Better approximations of the derivatives exist

10-120-2

10-1

-1-2-1000

121

81

81

Irwin SobelPalo Alto,2007

Page 5: UFO - Unidentified Flying Object Origin of Edges · UFO - Unidentified Flying Object Origin of Edges Edges are caused by a variety of factors depth discontinuity ... Edge detector

5

Gradient operators

(a): Roberts’ cross operator (b): 3x3 Prewitt operator(c): Sobel operator (d) 4x4 Prewitt operator

Example Edge

Original Gradient-X Gradient-Y

Gradient-Magnitude Gradient-Direction

Discrete Laplacian

Approximation of second derivative (horizontal):

= f''(x,y) = f'(x+1,y) - f'(x,y) == [f(x+1,y) - f(x,y)] - [f(x,y) - f(x-1,y)] = f(x+1,y) - 2 f(x,y) + f(x-1,y)

∂f2(x,y)∂2x

= convolution with: [ 1 -2 1]

Approximation of second derivative (vertical): convolution with

1-21

0 -1 0-1 4 -10 -1 0

Laplacian Operator ( + )∇2 = ∂2

∂x2∂2

∂y2

[ 1 -2 1] * =

1-21

Variations on Laplacian Operators:

0 -1 0-1 4 -10 -1 0

1 -2 1-2 4 -21 -2 1

-1 -1 -1-1 8 -1-1 -1 -1

All are approximations of:

Page 6: UFO - Unidentified Flying Object Origin of Edges · UFO - Unidentified Flying Object Origin of Edges Edges are caused by a variety of factors depth discontinuity ... Edge detector

6

Example of Laplacian Edge Detection

- =

Laplacian ~ Difference of gaussians

DOG = Difference of Gaussians

DOG in 2D

Laplacian of Gaussian

Gaussian delta function

Edge detection by subtraction

original

Page 7: UFO - Unidentified Flying Object Origin of Edges · UFO - Unidentified Flying Object Origin of Edges Edges are caused by a variety of factors depth discontinuity ... Edge detector

7

smoothed (5x5 Gaussian) smoothed – original(scaled by 4, offset +128)

Derivatives by Spectral AnalysisThe gradient vector at location (x,y) is:

( )( )

( )

( )⎟⎟⎟⎟

⎜⎜⎜⎜

∂∂∂

=⎟⎟⎠

⎞⎜⎜⎝

yyxf

xyxf

yxfyxf

y

x

,

,

,,

( ) ( )( ) ( )

2

2222

1111

1,,,,

maxarg ⎟⎟⎠

⎞⎜⎜⎝

⎥⎥⎥

⎢⎢⎢

= y

xyx

yx

u uu

yxfyxfyxfyxf

MM

For a local neighborhood Nx,y this direction also maximizes:

u∇f

ufff

fffu

yxy

yxyx

yxyx

yxx

T

u⎥⎥⎥

⎢⎢⎢

∑∑∑∑

=

,

2

,

,,

2

1maxarg

u∇f

λ1

λ2

smooth edge

edge

corner

Each entry in the 2x2 matrix can be implemented by a convolution

The above maximization amounts to finding the maximum eigen-vector of a 2x2 matrix:

Page 8: UFO - Unidentified Flying Object Origin of Edges · UFO - Unidentified Flying Object Origin of Edges Edges are caused by a variety of factors depth discontinuity ... Edge detector

8

Optimal Edge Detection: Canny

Assume: • Linear filtering• Additive iid Gaussian noise

Edge detector should have:• Good Detection. Filter responds to edge, not noise.• Good Localization: detected edge near true edge.• Single Response: one per edge.

J. Canny: A Computational Approach to Edge Detection, IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol. 8, No. 6, Nov. 1986.

Canny Edge detection – Step 1

• Convolve with derivatives (x and y) of Gaussians.• Calculate the magnitude of gradients.

Original

FA=f*Dx*G ((FA )2 + (FB)2 )1/2FB=f*Dy*G

Canny Edge detection – Step 2• Non-Maximum suppression (Thinning): Check if pixel

is local maximum along gradient direction• requires checking interpolated pixels p and r

Magnitude NonMaximum Supression

Page 9: UFO - Unidentified Flying Object Origin of Edges · UFO - Unidentified Flying Object Origin of Edges Edges are caused by a variety of factors depth discontinuity ... Edge detector

9

Gradient thresholding thinning(non-maximum suppression)

Canny Edge detection – Step 3: Hysteresis thresholding

High Threshold

Low Threshold

Edge Pixel

Non-Edge Pixel

Possible Edge Pixel

• Predicting the next edge point• Assume the marked point is an edge point. Then we

construct the tangent to the edge curve (which is normal to the gradient at that point) and use this to predict the next points (here either r or s).

• Check that maximum value of gradient value is sufficiently large• drop-outs? use hysteresis• use a high threshold to start edge curves and a low

threshold to continue them.

Page 10: UFO - Unidentified Flying Object Origin of Edges · UFO - Unidentified Flying Object Origin of Edges Edges are caused by a variety of factors depth discontinuity ... Edge detector

10

Low Threshold

HighThreshold

HysteresisThreshold

Magnitude(NonMax Suppressed)

Canny with σ = 1

original

Effect of ScaleEffect of σ (Gaussian kernel size)

Canny with σ = 2

An edge is not a line...

How can we detect lines ?

Finding lines in an image

Option 1:• Search for the line at every possible

position/orientation• What is the cost of this operation?

Option 2:• Use a voting scheme: Hough transform

Page 11: UFO - Unidentified Flying Object Origin of Edges · UFO - Unidentified Flying Object Origin of Edges Edges are caused by a variety of factors depth discontinuity ... Edge detector

11

The Hough Transform

• A line in the image space corresponds to a point in Hough space

x

y

m

b

m0

b0

image space Hough space

Finding lines in an image

x

y

m

b

image space Hough spacex0

y0

• A point in the image space corresponds to a line in Hough space

Demo: http://www.rob.cs.tu-bs.de/content/04-teaching/06-interactive/Hough.html

Hough transform algorithmTypically use a different parameterization (why?)

• d is the perpendicular distance from the line to the origin• θ is the angle this perpendicular makes with the x axis

x

y

θ

x

yd (θ0,d0)

Image space Hough space

x

y

θ

d

Image Domain Hough Domain

Page 12: UFO - Unidentified Flying Object Origin of Edges · UFO - Unidentified Flying Object Origin of Edges Edges are caused by a variety of factors depth discontinuity ... Edge detector

12

x

y d

Hough Transform Algorithm

θ

Basic Hough transform algorithm1. Initialize H[d, θ]=02. for each edge point I[x,y] in the image

for θ = 0 to 180 H[d, θ] += 1

3. Find the value(s) of (d, θ) where H[d, θ] is maximum4. The detected line in the image is given by

What’s the running time (measured in # votes)?

Hough Transform Example

Hough Transform (s,θ) space

Original square image

Reconstructed line segments

Hough Transform Example

Original Edges Hough Transform

Results

Extensions

• Use the gradient directions.• give more votes for stronger edges.• Distributed votes.• The same procedure can be used with circles,

squares, or any other shape.

Page 13: UFO - Unidentified Flying Object Origin of Edges · UFO - Unidentified Flying Object Origin of Edges Edges are caused by a variety of factors depth discontinuity ... Edge detector

13

Hough Transform for Circles

x

y (x0,y0,r)

Image space Hough space

Image Domain Hough Domain

r2 = (x-x0)2+(y-y0)2

(x0,y0)r

y0

x0

r

T H E E N D