edge detection

75
Computer Vision Group Edge Detection 27 th November 2012 /

Upload: berg

Post on 24-Feb-2016

105 views

Category:

Documents


0 download

DESCRIPTION

Edge Detection. 27 th Nov ember 2012 /. Edge Detection in Images. Goal: Automatically find the contour of objects in a scene. What For: Edges are significant descriptors, useful for classification, compression…. Edge Detection in Images. What is an object? - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Edge Detection

Computer Vision Group

Edge Detection27th November 2012

/

Page 2: Edge Detection

Computer Vision Group

Edge Detection in Images

Goal: Automatically find the contour of objects in a scene.

What For: Edges are significant descriptors, useful for classification, compression…

06/12/2011

Page 3: Edge Detection

Computer Vision Group

Edge Detection in Images

What is an object?It is one of the goals of computer vision to identify objects in scenes.

06/12/2011

Page 4: Edge Detection

Computer Vision Group

Edges May Have Different Sources

Object Boundaries Occlusions Textures Shading

06/12/2011

Page 5: Edge Detection

Computer Vision Group

What is an Edge

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

Several Models• Step Edge• Ramp Edge• Roof Edge• Spike Edge

They can bethus detected asdiscontinuitiesof image Derivatives

06/12/2011

Page 6: Edge Detection

Computer Vision Group

Differentiation and convolution

Recall

Now this is linear and shift invariant. Therefore, in discrete domain, it will be represented as a convolution

xfxfxf

0lim

06/12/2011

Page 7: Edge Detection

Computer Vision Group

Differentiation and convolution

Recall

Now this is linear and shift invariant. Therefore, in discrete domain, it will be represented as 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)

xfxfxf

0lim

xxfxf

xf n

1

11

06/12/2011

Page 8: Edge Detection

Computer Vision Group

Finite Difference in 2D

yxfyxfx

yxf ,,lim,0

yxfyxfy

yxf ,,lim,0

x

yxfyxfx

yxf mnmn

,,, 1

x

yxfyxfy

yxf mnmn

,,, 1

11

11

Discrete Approximation

Horizontal

Convolution Kernels

Vertical

06/12/2011

Page 9: Edge Detection

Computer Vision Group

A 1D Example

Take a line on a grayscale image

06/12/2011

Page 10: Edge Detection

Computer Vision Group

A 1D Example (II)

Filter the discrete image values, convolution against [1 -1]

06/12/2011

Page 11: Edge Detection

Computer Vision Group

Differentiating Filters

)1()1()( xfxfxf x

1D Discrete derivatives

1 0 -1*ff x

2D Discrete derivatives (separable)

*ff y 1 0 -1 t

06/12/2011

Page 12: Edge Detection

Computer Vision Group

Classical Operators : Prewitt

111111

11

11

Smooth Differentiate

101101101

111000111

111111

Horizontal

Vertical

06/12/2011

Page 13: Edge Detection

Computer Vision Group

Classical Operators: Sobel

112211

11

11

Smooth Differentiate

101202101

121000121

121121

Horizontal

Vertical

06/12/2011

Page 14: Edge Detection

Computer Vision Group

Another famous test image - cameraman

06/12/2011

Page 15: Edge Detection

Computer Vision Group

Horizontal Derivatives using Sobel

1 * ty y h

06/12/2011

Page 16: Edge Detection

Computer Vision Group

Vertical Derivatives using Sobel

2 * ty y h

06/12/2011

Page 17: Edge Detection

Computer Vision Group

Gradient Magnitude and edge detectors

2 2| | * *ty y h y h

06/12/2011

Page 18: Edge Detection

Computer Vision Group

Finite differences

11* II x

1

1*II y

I06/12/2011

Page 19: Edge Detection

Computer Vision Group

The Gradient Orientation

Like for continuous function, the gradient at each pixel points at the steepest intensity growth direction.

The gradient norm indicates the inclination of the intensity growth.

Matlab…..

06/12/2011

Page 20: Edge Detection

Computer Vision Group

Finite differences responding to noise

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

06/12/2011

Page 21: Edge Detection

Computer Vision Group

Finite differences responding to noise

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

06/12/2011

Page 22: Edge Detection

Computer Vision Group

Finite differences responding to noise

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

06/12/2011

Page 23: Edge Detection

Computer Vision Group

Smoothing reduces noise

Generally expect pixels to “be like” their neighbors• surfaces turn slowly• relatively few reflectance changes

Generally expect noise processes to be independent from pixel to pixel and with zero mean

Implies that smoothing suppresses noise, (i.i.d. noise!)

Gaussian Filtering• 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 somehow suppressed

06/12/2011

Page 24: Edge Detection

Computer Vision Group

Smoothing reduces noise

Generally expect pixels to “be like” their neighbors• surfaces turn slowly• relatively few reflectance changes

Generally expect noise processes to be independent from pixel to pixel and with zero mean

Implies that smoothing suppresses noise, (i.i.d. noise!)

Gaussian Filtering• 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 somehow suppressed

06/12/2011

Page 25: Edge Detection

Computer Vision Group

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

Low - Pass

06/12/2011

Page 26: Edge Detection

Computer Vision Group

Gradient Magnitude and edge detectors

2 2| | * *ty y h y h

Gradient Magnitute is not a binary image -> “shows edges” but “does not allow to identify them” yet

06/12/2011

Page 27: Edge Detection

Computer Vision Group

Sobel Edge Detector

Detecting Edges in Image

Image I

101202101

121000121

*

*

Idxd

Idyd

22

I

dydI

dxd

ThresholdEdges

any alternative ?

Discrete Derivatives Gradient Norms Threshold

06/12/2011

Page 28: Edge Detection

Computer Vision Group

Canny Edge Detector Criteria

Good Detection: The optimal detector must minimize the probability of false positives as well as false negatives.

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. similar to good detection but requires an ad-hoc formulation to get rid of multiple responses to a single edge

06/12/2011

Poor robustness to noise Poor localization Too many responsesTrue Edge

Page 29: Edge Detection

Computer Vision Group

Canny Edge Detector

Basically 3 steps• Convolution with derivative of Gaussian• Non-maximum Suppression• Hysteresis Thresholding

J. Canny “A Computational Approach to Edge Detection” IEEE PAMI vol 8, no. 6, Nov. 1986http://perso.limsi.fr/Individu/vezien/PAPIERS_ACS/canny1986.pdf

06/12/2011

Page 30: Edge Detection

Computer Vision Group

Canny Edge Detector

Smooth by Gaussian

Compute x and y derivatives

Compute gradient magnitude and orientation

IGS *2

22

2

21

yx

eG

Tyx

T

SSSy

Sx

S

22yx SSS

x

y

SS1tan

06/12/2011

Page 31: Edge Detection

Computer Vision Group

Canny Edge Operator

IGIGS ** T

yG

xGG

T

Iy

GIx

GS

**

06/12/2011

Page 32: Edge Detection

Computer Vision Group

Canny Edge Detector

xS

yS

I

06/12/2011

Page 33: Edge Detection

Computer Vision Group

An Overview on Threshold

According to the way the Threshold T is used/determined they are divided into• Global Threshold• Local (or) Adaptive Threshold

According to the output they can be classified in • Binary Threshold• Hard Threshold• Soft Threshold

Matlab…

06/12/2011

Page 34: Edge Detection

Computer Vision Group

Canny Edge Detector

I

22yx SSS

25 ThresholdS

06/12/2011

Page 35: Edge Detection

Computer Vision Group

Non-Maximum Suppression: The Idea

We wish to determine the points along the curve where the gradient magnitude is largest.

Non-maximum suppression: we look for a maximum along a slice orthogonal to the curve. These points form a 1D curve.

There are two issues:• which point is the maximum, • and where is the next one?

06/12/2011Original Image Gradient Magnitude Segment orthogonal

Page 36: Edge Detection

Computer Vision Group

Non-Maximum Suppression: Quantize Gradient Directions

For each pixel compute gradient direction and quantize it in 4 main direction, each covering 45° (orientation is not considered)

For each pixel buld up a segment following the quantized directions 0,1,2,3

06/12/2011

0

12

3

41420tan41422- :3

41422tan :241422tan41420 :141420tan41420 :0

.θ.

.θ.θ..θ.-

x

y

SS

θ tan

06/12/2011

Page 37: Edge Detection

Computer Vision Group

Non-Maximum Suppression – Idea (II)

06/12/2011

The intensity profile along the segment

A segment orthogonal to the gradient directionin a pixel

Page 38: Edge Detection

Computer Vision Group

Non-Maximum Suppression - Threshold

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

and are the

neighbors of in

x , y x , y

x, y S

otherwise0,,&

,, if,, yxSyxS

yxSyxSyxSyxM

yx ,

yx,

yx , These have to be taken on a line along the direction orthogonal to the gradient in (x,y)

06/12/2011

Page 39: Edge Detection

Computer Vision Group

Non-Maximum Suppression

22yx SSS M

25ThresholdM06/12/2011

Page 40: Edge Detection

Computer Vision Group

Hysteresis Thresholding

Use of two different threshold High and Low for • For new edge starting point• For continuing edges

In such a way the edges continuity is preserved

06/12/2011

Page 41: Edge Detection

Computer Vision Group

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’.

06/12/2011

Page 42: Edge Detection

Computer Vision Group

Hysteresis Thresholding

M 25ThresholdM

15 35

LowHigh

06/12/2011

Page 43: Edge Detection

Computer Vision Group

Examples

an image its detected edges

06/12/2011

Page 44: Edge Detection

Computer Vision Group

In matlab..

Canny edge detector is implemented with theedge.m command

06/12/2011

Page 45: Edge Detection

Computer Vision Group

A brief overview on Morphological Operators in Image Processing

Giacomo Boracchi24/11/2010

[email protected]

home.dei.polimi.it/boracchi/teaching/IAS.htm

Page 46: Edge Detection

Computer Vision Group

An overview on morphological operations

Erosion, Dilation

Open, Closure

We assume the image being processed is binary, as these operators are typically meant for refining “mask” images.

06/12/2011

Page 47: Edge Detection

Computer Vision Group

AND operator in Binary images

06/12/2011

Page 48: Edge Detection

Computer Vision Group

OR in Binary Images

06/12/2011

Page 49: Edge Detection

Computer Vision Group

Erosion

General definition: Nonlinear Filtering procedure that replace to each pixel valuethe minimum on a given neighbor

As a consequence on binary images

E(x)=1 iff the image in the neighbor is constantly 1

This operation reduces thus the boundaries of binary images

It can be interpreted as an AND operation of the image and the neighbor overlapped at each pixel

06/12/2011

Page 50: Edge Detection

Computer Vision Group

Erosion Example

06/12/2011

Page 51: Edge Detection

Computer Vision Group

Erosion Example

06/12/2011

Page 52: Edge Detection

Computer Vision Group

Dilation

General definition: Nonlinear Filtering procedure that replace to each pixel valuethe maximum on a given neighbor

As a consequence on binary images

E(x)=1 iff at least a pixel in the neighbor is 1

This operation grows fat the boundaries of binary images

It can be interpreted as an OR operation of the image and the neighbor overlapped at each pixel

06/12/2011

Page 53: Edge Detection

Computer Vision Group

Dilation Example

06/12/2011

Page 54: Edge Detection

Computer Vision Group

Dilation Example

06/12/2011

Page 55: Edge Detection

Computer Vision Group

In matlab

They are performed using the

bwmorph.m script passing the name of the operation as a parameter

Examples…

06/12/2011

Page 56: Edge Detection

Computer Vision Group

Open and Closure

Open Erosion followed by a Dilation

Closure Dilation followed by an Erosion

06/12/2011

Page 57: Edge Detection

Computer Vision Group

Open

Open Erosion followed by a Dilation• Smoothes the contours of an object• Typically eliminate thin protrusions

06/12/2011

Page 58: Edge Detection

Computer Vision Group

Open

Figure to Open,

Structuring element a Disk

06/12/2011

Page 59: Edge Detection

Computer Vision Group

Open

First Erode,

06/12/2011

Page 60: Edge Detection

Computer Vision Group

Open

Then Dilate,

Open results, the bridge has been eliminate from the first erosion and cannot be replaced by the dilation.

Edges are smoothed

Corners are rounded

06/12/2011

Page 61: Edge Detection

Computer Vision Group

Closure

Closure Dilation followed by an Erosion• Smoothes the contours of an object, typically creates• Generally fuses narrow breaks

06/12/2011

Page 62: Edge Detection

Computer Vision Group

Open

Figure to Open,

Structuring element a Disk

06/12/2011

Page 63: Edge Detection

Computer Vision Group

Close

First Dilate,

06/12/2011

Page 64: Edge Detection

Computer Vision Group

Close

Then Erode,

Close results, the bridge has been preserved

Edges are smoothed

Corners are rounded

06/12/2011

Page 65: Edge Detection

Computer Vision Group

There are several other Non Linear Filters

Ordered Statistic based• Median Filter • Weight Ordered Statistic Filter• Trimmed Mean• Hybrid Median

Thresholding

06/12/2011

Page 66: Edge Detection

Computer Vision Group

Fitting – A brief Introduction

We assume that the images are generated from a “straight lines” word.

By performing edge detection we are only able to select those pixels that belongs to an edge

We are not able to determine if such an edge is a straight line, and in case it is, which are the parameters of such line

06/12/2011

Page 67: Edge Detection

Computer Vision Group

Fitting – A brief Introduction

Let now assume we are interested in detecting lines only, and we want to determine the parameters of such a lines

Line Fitting can be performed via • Hough Transform• Error minimization• Maximum Likelihood

But we have to determine first how the process generating data is:i.e. • Observation are noisy, how is noise affecting straight lines?

06/12/2011

Page 68: Edge Detection

Computer Vision Group

There are different noise models 1. Noise displaces line pixels orthogonally to the straight line and it

is gaussian distributed2. Noise displaces line pixels only along the y coordinate and it is

gaussian distributed

Then, in both case there exist a closed form solution

Or it can be performed via numerical minimization … matlab

Fitting – A brief Introduction

06/12/2011

Page 69: Edge Detection

Computer Vision Group

Fitting and Convolution

One can prove that the least square fit of polynomial of 0-th order (i.e constant) is given by

where

and thus

06/12/2011

Page 70: Edge Detection

Computer Vision Group

Frequency Response of Differential Kernel

xfx ufuFFourier

Transform

xf ufFFourierTransform

06/12/2011

Page 71: Edge Detection

Computer Vision Group

Canny Edge Detector

Difficult to find closed-form solutions.

06/12/2011

Page 72: Edge Detection

Computer Vision Group

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)

06/12/2011

Page 73: Edge Detection

Computer Vision Group

Finite differences and noise

Finite difference filters respond strongly to noise• obvious reason: image noise results in pixels that look

very different from their neighbors

The more relevant is the noise, the stronger the response

06/12/2011

Page 74: Edge Detection

Computer Vision Group

Finite differences and noise

What is to be done?• intuitively, most pixels in images look quite a lot like their

neighbors.• 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 neighbors (=noise pixels?) to look more like neighbors.

06/12/2011

Page 75: Edge Detection

Computer Vision Group

Gaussian Filter

2

22

2 2exp

21,

yxyxG

2

22

2 211exp

21,

kjkijiH

array 1212 is , where kkjiH

06/12/2011