edge detection. edge detection in images finding the contour of objects in a scene

35
Edge detection

Post on 19-Dec-2015

221 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Edge detection

Page 2: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Edge Detection in Images

• Finding the contour of objects in a scene

Page 3: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Edge Detection in Images

• What is an object?

It is one of the goals of computer vision to identify objects in scenes.

Page 4: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Edge Detection in Images

• Edges have different sources.

Page 5: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

What is an Edge

• Lets define an edge to be a discontinuity in image intensity function.

• Edge Models– Step Edge– Ramp Edge– Roof Edge– Spike Edge

Page 6: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Detecting Discontinuities

• Discontinuities in signal can be detected by computing the derivative of the signal.

Page 7: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Differentiation and convolution

• Recall

• Now this is linear and shift invariant, so must be the result of a convolution.

• We could approximate this as

(which is obviously a convolution with Kernel

; it’s not a very good way to do things, as we shall see)

xfxf

x

f0

lim x

xfxf

x

f n

1

11

Page 8: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Finite Difference in 2D

yxfyxf

x

yxf ,,lim

,0

yxfyxf

y

yxf ,,lim

,0

x

yxfyxf

x

yxf mnmn

,,, 1

x

yxfyxf

y

yxf mnmn

,,, 1

11

1

1

Discrete Approximation

Definition

Convolution Kernels

Page 9: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Finite differences

11* II x

1

1*II y

I

Page 10: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Frequency Response of Differential Kernel

xfx ufuF

Fourier

Transform

xf ufFFourier

Transform

Page 11: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Noise

• Simplest noise model– independent stationary

additive Gaussian noise

– the noise value at each pixel is given by an independent draw from the same normal probability distribution

• Issues– this model allows noise

values that could be greater than maximum camera output or less than zero

– for small standard deviations, this isn’t too much of a problem - it’s a fairly good model

– independence may not be justified (e.g. damage to lens)

– may not be stationary (e.g. thermal gradients in the ccd)

Page 12: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Finite differences and noise

• Finite difference filters respond strongly to noise– obvious reason: image

noise results in pixels that look very different from their neighbours

• Generally, the larger the noise the stronger the response

• What is to be done?– intuitively, most pixels in

images look quite a lot like their neighbours

– this is true even at an edge; along the edge they’re similar, across the edge they’re not

– suggests that smoothing the image should help, by forcing pixels different to their neighbours (=noise pixels?) to look more like neighbours

Page 13: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Finite differences responding to noise

Increasing noise ->(this is zero mean additive gaussian noise)

Page 14: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Smoothing reduces noise

• Generally expect pixels to “be like” their neighbours– surfaces turn slowly– relatively few

reflectance changes

• Generally expect noise processes to be independent from pixel to pixel

• Implies that smoothing suppresses noise, for appropriate noise models

• Scale– the parameter in the

symmetric Gaussian– as this parameter goes

up, more pixels are involved in the average

– and the image gets more blurred

– and noise is more effectively suppressed

Page 15: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

The effects of smoothing Each row shows smoothingwith gaussians of differentwidth; each column showsdifferent realisations of an image of gaussian noise.

Page 16: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Classical Operators

Prewitt’s Operator

11

11

11

1

1

11

SmoothDifferentiate

101

101

101

111

000

111

111

111

Page 17: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Classical Operators

Sobel’s Operator

11

22

11

1

1

11

SmoothDifferentiate

101

202

101

121

000

121

121

121

Page 18: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Gaussian Filter

2

22

2 2exp

2

1,

yx

yxG

2

22

2 2

11exp

2

1,

kjki

jiH

array 1212 is , where kkjiH

Page 19: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

• Sobel Edge Detector

Detecting Edges in Image

Image I

101

202

101

121

000

121

*

*

Idx

d

Idy

d

22

Idy

dI

dx

d

ThresholdEdges

any alternative ?

Page 20: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Quality of an Edge Detector

• Robustness to Noise

• Localization

• Too Many/Too less Responses

Poor robustness to noise Poor localization Too many responses

True Edge

Page 21: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Canny Edge Detector• Criterion 1: Good Detection: The optimal

detector must minimize the probability of false positives as well as false negatives.

• Criterion 2: Good Localization: The edges detected must be as close as possible to the true edges.

• Single Response Constraint: The detector must return one point only for each edge point.

Page 22: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Canny Edge Detector

• Difficult to find closed-form solutions.

Page 23: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Canny Edge Detector

• Convolution with derivative of Gaussian

• Non-maximum Suppression

• Hysteresis Thresholding

Page 24: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Canny Edge Detector• Smooth by Gaussian

• Compute x and y derivatives

• Compute gradient magnitude and orientation

IGS * 2

22

2

2

1

yx

eG

Tyx

T

SSSy

Sx

S

22yx SSS

x

y

S

S1tan

Page 25: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Canny Edge Operator

IGIGS ** T

y

G

x

GG

T

Iy

GI

x

GS

**

Page 26: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Canny Edge Detector

xS

yS

I

Page 27: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Canny Edge Detector

I

22yx SSS

25 ThresholdS

Page 28: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

We wish to mark points along the curve where the magnitude is biggest.We can do this by looking for a maximum along a slice normal to the curve(non-maximum suppression). These points should form a curve. There arethen two algorithmic issues: at which point is the maximum, and where is thenext one?

Non-Maximum Suppression

Page 29: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Non-Maximum Suppression

• Suppress the pixels in ‘Gradient Magnitude Image’ which are not local maximum

edgean tonormaldirection thealong

in of neighbors theare and Sx,yy,xy,x

otherwise0,,&

,, if,

, yxSyxS

yxSyxSyxS

yxM yx ,

yx,

yx ,

Page 30: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Non-Maximum Suppression

0

12

3

41420tan41422- :3

41422tan :2

41422tan41420 :1

41420tan41420 :0

.θ.

.θ.

.θ.-

x

y

S

Sθ tan

Page 31: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Non-Maximum Suppression

22yx SSS M

25ThresholdM

Page 32: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Hysteresis Thresholding

Page 33: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Hysteresis Thresholding

• If the gradient at a pixel is above ‘High’, declare it an ‘edge pixel’

• If the gradient at a pixel is below ‘Low’, declare it a ‘non-edge-pixel’

• If the gradient at a pixel is between ‘Low’ and ‘High’ then declare it an ‘edge pixel’ if and only if it is connected to an ‘edge pixel’ directly or via pixels between ‘Low’ and ‘ High’

Page 34: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

Hysteresis Thresholding

M 25ThresholdM

15

35

Low

High

Page 35: Edge detection. Edge Detection in Images Finding the contour of objects in a scene

an image its detected edges