Advanced Edge Detection Techniques-b

43
ADVANCED EDGE DETECTION TECHNIQUES The Canny and the Shen - Castan Methods

description

Advanced Edge Detection Techniques

Transcript of Advanced Edge Detection Techniques-b

Page 1: Advanced Edge Detection Techniques-b

ADVANCED EDGE DETECTION TECHNIQUES

The Canny and the Shen - Castan Methods

Page 2: Advanced Edge Detection Techniques-b

Edge Detection

• An edge is a boundary between an object and the background, and indicates the boundary between overlapping objects.

• Edges form the outline of an object, so if the edges are identified in an image accurately, then all the objects can be located and basic properties such as area, perimeter can be measured.

• Edge detection is based on the relationship a pixel has with its neighbors.

Page 3: Advanced Edge Detection Techniques-b

Edge Detection

• Edges, in an image are defined as locations where there is a significant variation in the gray level or color of pixel in some direction.

• Edge detection extracts and localizes points (pixels) around which a large change in image brightness has occurred.

• This can help in the process of segmentation

Page 4: Advanced Edge Detection Techniques-b

Traditional Approaches

Ideal Step Edge :- (The most common definition of an edge)

• In 1-d the edge is simply a change in gray level occurring at one specific location (fig.1a).

• The greater the change in the level, the easier the edge is to detect.

Page 5: Advanced Edge Detection Techniques-b

Step Edge Detection

Page 6: Advanced Edge Detection Techniques-b

Problems in Edge Detection

• Problems:-1)Because of digitization:-The image may be

sampled in such a way so that change in gray level may extend across some number of pixels. Fig 1b-d.

2)Because of noise:-Due to factors such as light intensity, type of camera and lens, motion, temperature, dust and others.

Page 7: Advanced Edge Detection Techniques-b

Noise

Two types of noise are of interest in image analysis:-

1) Signal –independent:-noise is a random set of gray levels, statistically independent of the data. It occurs during electronically transmission of image. If A is a perfect image and N is the noise that occurs during transmission, then the final image B is

B = A + N

2) Signal-dependent noise:- In this the level of the noise value at each point in the image is a function of the grey level there.

Page 8: Advanced Edge Detection Techniques-b

Derivative Operators

• An operator, that is sensitive to change in gray level will operate as an edge detector- A derivative operator does this.

• Interpretation of derivative:- The rate of change of function. The rate of change of the gray levels in an image is large near an edge and small in constant areas.

• In images are 2-D, so level changes are considered in many directions. For this reason partial derivatives of the image are used with respect to the principal directions x and y.

Let A (x, y) be an image then the gradient is defined as:

∆A (x ,y) = (∂A / ∂x, ∂A / ∂y)

Page 9: Advanced Edge Detection Techniques-b

Gradient operators

Because image is discrete, the derivative at a pixel is approximated by the difference in gray levels over some local region.

The simplest approximation is the operator ∆1:

Δx1A(x, y) = A(x, y) – A(x-1, y)

Δx2A(x, y) = A(x, y) – A(x, y-1)

Problem with this operator:- It does not compute the gradient at the point (x, y), but at (x-1/2, y-1/2)

Assumption:- the grey levels vary linearly between the pixels.

Page 10: Advanced Edge Detection Techniques-b

Gradient operators

A better choice for an approximation is

Δx2 A(x, y) = A(x+1, y) – A(x-1 ,y)

Δy2 A(x, y) = A(x, y+1) – A(x, y-1)

This operator is symmetrical with respect to the pixel (x, y). It does not consider the value of the pixel at (x, y).

The edge response is given by:

Gmag = √((∂A ⁄ ∂x)2 + (∂A ⁄∂y)2)

Page 11: Advanced Edge Detection Techniques-b

Gradient operators

and the direction of the edge is approximately:

Gdir = atan (∂A ⁄∂y) ⁄ ( ∂A ⁄ ∂x)

Edge pixel- which exceeds the threshold value

Page 12: Advanced Edge Detection Techniques-b

Gradient operators examples

Page 13: Advanced Edge Detection Techniques-b

Examples

Page 14: Advanced Edge Detection Techniques-b

Examples

Page 15: Advanced Edge Detection Techniques-b

Measures of Performance of Edge Detection Schemes

• False Positive• False Negative• Using Function (Pratt 1978)

E1 =∑(1/(1+αd(i)2)) / max(IA,II)

IA = the number of edge pixels found by the edge detector

II= the number of edge pixels in the test image d(i)=the distance between the actual ith pixel and the one

found by the edge detectorα is used for scaling

Page 16: Advanced Edge Detection Techniques-b

Measures of Performance

• Evaluation scheme based on local edge coherence (Kitchen and Rosenfeld)

(a) It measures how well an edge pixel is continued on the left; this function is

L(k) =a(d,dk) a(kπ/4,d+π/2) if neighbor k is an edge pixel

0 otherwise

where d is the edge direction at the pixel being tested

d0 is the edge direction at its neighbor to the right

d1 is the direction of the upper-right neighbor, and so on

Counterclockwise about the pixel involved

a= the measure of the angular difference between any two angles

Page 17: Advanced Edge Detection Techniques-b

Measures…

a(α,β) = π -|α-β| ⁄ π

(b) A similar function measures directional continuity on the right of the pixel being evaluated:

R(k) = a(d,dk) a(kπ/4,d+π/2) if neighbor k is an edge pixel 0 otherwise(c) C= Overall continuity measure = average(L(k), R(k))(d) Then measure of thinness (T) is applied.(e) The overall evaluation of the edge detector is:

(f) E2 = γC + (1-γ) T

Page 18: Advanced Edge Detection Techniques-b

Template-Based Edge Detection

• This uses a small, discrete template as a model of an edge instead of using a derivative operator.

• Exampes:-

(a) Sobel Edge Detector

(b) Kirsch Edge Detector

Page 19: Advanced Edge Detection Techniques-b

Sobel Edge Detector

• It uses templates in the form of convolutional masks having the following values.

-1 -2 -1 -1 0 1

0 0 0 = SY -2 0 2 = Sx

1 2 1 -1 0 1

For a pixel at image coordinates (I,j), SX SY can be computed by

Page 20: Advanced Edge Detection Techniques-b

Sobel Edge Detector

SX = I[i-1][j+1]+2I[i][j+1]+I[i+1][j+1]- (I[i-1][j-1]+2I[i][j-1]+I[i+1][j-1])

SY = I[i+1][j+1]+2I[i+1][j]+I[i+1][j-1]-(I[i-1][j+1]+ 2I[i-1][j]+I[i-1][j-1])

• After SX Sy are computed for each pixel, resulting magnitude must be thresholded

Page 21: Advanced Edge Detection Techniques-b

Figure

Page 22: Advanced Edge Detection Techniques-b

Kirsch Edge Detector

• These templates has different motivation than Sobel’s.• For the 3X3 case the templates are:

-3 -3 5 -3 5 5 5 5 5 5 5 -3

K0= -3 0 5 K1=-3 0 5 K2= -3 0 -3 K3= 5 0 -3

-3 -3 5 -3 -3 -3 -3 -3 -3 -3 -3 -3

5 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3

K4=5 0 -3 K5= 5 0 -3 K6= -3 0 -3 K7= -3 0 5

5 -3 -3 5 5 -3 5 5 5 -3 5 5

Page 23: Advanced Edge Detection Techniques-b

Kirsch Edge Detector

•These masks are to observe the grey level change near an edge having various orientations, rather than approximation to the gradient.•There are one mask for each of eight compass directions.•For example, a large response to mask K0 implies a vertical edge (horizontal gradient) at the pixel corresponding to the center of the mask.

Method:-•To find the edges, an image I is convolved with all of the masks at each pixel position. The response of the operator at a pixel is the maximum of the responses of any of the eight masks. The direction of the edge pixel is quantized into eight possibilities and is π /4 *I where I is the number of the mask having the largest response.

Page 24: Advanced Edge Detection Techniques-b

EDGE MODELS : Marr- Hildreth Edge Detection

Marr studied the literature on mammalian visual systems and summarized these in five major points:-

1. In natural images, features of interest occur at a variety of scales. No single operator can function at all of these scales, so the result of operations at each of scales should be combined.

2. Diffraction patterns does not occur in a natural scene, so some local averaging (smoothing) must take place.

Page 25: Advanced Edge Detection Techniques-b

Marr-Hildreth Edge Detection

3.The optimal smoothing filter that matches the observed requirements of biological vision is the Gaussian.

4. When a change in intensity (edge) occurs, there is an extreme value in the first derivative or intensity. This corresponds to a zero crossing in the second derivative.

5. The orientation-independent differential operator of lowest order is the Laplacian.

Page 26: Advanced Edge Detection Techniques-b

Marr-Hildreth Edge Detection Algorithm

1. Convolve the image I with a two- dimensional Gaussian function.

2. Complete the Laplacian of the convolved image; call this L

3. Edge pixels are those for which there is a zero crossing in L.

Page 27: Advanced Edge Detection Techniques-b

Marr…

• A convolution in two dimensions is given by:

I* G(I, j) =∑ ∑I(n, m) G(i-n, j-m) n m

• The function G being convolved with the image is a two dimensional Gaussian:

Gσ(x, y) = σ2 exp{-(x2 + y2) ⁄ σ2

Gaussian must be sampled to create

Page 28: Advanced Edge Detection Techniques-b

Marr…

a small two dimensional image.

• After the convolution, the Laplacian operator can be applied.

Δ2 = ∂2 ⁄ ∂x2 + ∂2 ⁄ ∂y2

Page 29: Advanced Edge Detection Techniques-b

Examples

Page 30: Advanced Edge Detection Techniques-b

Examples

Page 31: Advanced Edge Detection Techniques-b

Strength and weaknesses

Advantage:

This is much better than the previous ones in cases of low signal to noise ratio.

Disadvantages of the method:-

1) Low evaluation.

2) Locality is not good, the edges are not always thin.

Page 32: Advanced Edge Detection Techniques-b

The Canny Edge Detector

Canny specified three issues that an edge detector must address. They are:-

1.Error rate:-The edge detector should respond only to edges, and should find all of them; no edges should be missed.

2.Localization:- The distance between the edge pixels as found by the edge detector and the actual edge should be as small as possible.

3.Response:- The edge detector should not identify multiple edge pixels where only a single edge exists.

Page 33: Advanced Edge Detection Techniques-b

Canny Edge Detector

• Canny assumed that a step edge subject to white Gaussian noise.• The edge detector was assumed to be a convolution filter f that would smooth the noise and locate the edge. •So the problem is to identify the one filter that optimizes the three

edge detection criteria. •In one –dimension, the response of the filter f to an edge G is

given by a convolution integral -W

H = ∫ G(-x)f(x)dx W

Page 34: Advanced Edge Detection Techniques-b

Canny…

•The filter is assumed to be zero outside of the region [-W, W].•Mathematically the three criteria are expressed as:

0 W

SNR= (A | ∫ f(x) dx | ) ⁄ n0 √ ∫ f2(x) dx

-W -W

W

Localization = A | f(0)| ⁄ n0 √ ∫ f2(x) dx

-W

Page 35: Advanced Edge Detection Techniques-b

Canny…

∞ ∞

xzc = π (∫ f2(x) dx ) ⁄ ( ∫ f ‘ 2(x) dx)

-∞ -∞

•The value of SNR is the error rate.•The localization value represents the reciprocal of the distance of the located edge from the true edge.•The value of xzc is the mean distance between zero crossings of f’.

Page 36: Advanced Edge Detection Techniques-b

The Canny Edge Detection Algorithm

• Read in the image to be processed I.• Create a 1D Gaussian mask G to convolve with I. The standard deviation s of this Gaussian is a parameter to the edge detector.• Create a 1D mask for the first derivative of the Gaussian in the x and y directions; call these Gx and Gy. The same s value is used as in step 2.

Page 37: Advanced Edge Detection Techniques-b

Canny Edge Detection ( continued)

•Convolve the image I with G along the rows to give the x component image IX, and down the columns to give the y component image Iy.• Convolve IX with GX to give IX’ , the x component of I convolved with the derivative of the Gaussian function and • Convolve IY with GY to give IY’.• To view the result the x and y component must be combined. The magnitude of the result at pixel (x,y) is

M(x,y) = √ IX’(x,y)2 + IY’(x,y)2

Page 38: Advanced Edge Detection Techniques-b

Canny..

• The final step in the Canny edge detector is a nonmaximum suppression step, where pixels that are not local maxima are removed.

• As an extra step, Canny suggests thresholding using hysteresis rather than simply selecting a threshold value to apply everywhere. Hysteresis thresholding uses a high threshold Th and low threshold Tl.

Page 39: Advanced Edge Detection Techniques-b

Examples: Canny

Page 40: Advanced Edge Detection Techniques-b

Examples : Canny

Page 41: Advanced Edge Detection Techniques-b

The Shen-Castan (ISEF) Edge Detector

•Canny’s detector defined optimally with respect to a specific set of criteria.•Shen and Casten used different function to optimize following function for 1D):

C2N =( 4 ∫ f2(x)dx. ∫ f’2(x)dx) ⁄ f4(0)

•The function that minimizes CN is the optimal smoothing function filter for an edge detector.•The optimal filter function they used is the infinite symmetric exponential filter (ISEF): f(x) =( p/2 ) exp(-p|x|)

Page 42: Advanced Edge Detection Techniques-b

Comparison of Two Optimal Edge Detectors

• Shen-Castan method provides better S/N than Canny’s filter.It also provides better localization than Canny’s operator.This is because the implementation of Canny’s algorithm approximates his optimal filter by the derivative of a Gaussian, whereas Shen use the optimal filter directly.

• Since Shen method does not address the multiple response criterion, it is possible that their method will create spurious response to noisy and blurred edges.

Page 43: Advanced Edge Detection Techniques-b

Figures