canny edge detector

16
October 9, 2014 Computer Vision Lecture 10: Edge Detection 1 Canny Edge Detector However, usually there will still be noise in the array E[i, j], i.e., non- zero values that do not correspond to any edge in the original image. In most cases, these values will be smaller than those indicating actual edges. We could then simply use a threshold to eliminate the noise, as we did before. However, this could still leave some isolated edge outputs caused by strong noise and some gaps in detected contours.

Upload: dayshaun-matthew

Post on 30-Dec-2015

29 views

Category:

Documents


0 download

DESCRIPTION

Canny Edge Detector. However, usually there will still be noise in the array E[ i , j], i.e., non-zero values that do not correspond to any edge in the original image. In most cases, these values will be smaller than those indicating actual edges. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Canny Edge Detector

October 9, 2014 Computer Vision Lecture 10: Edge Detection III

1

Canny Edge Detector

However, usually there will still be noise in the array E[i, j], i.e., non-zero values that do not correspond to any edge in the original image.

In most cases, these values will be smaller than those indicating actual edges.

We could then simply use a threshold to eliminate the noise, as we did before.

However, this could still leave some isolated edge outputs caused by strong noise and some gaps in detected contours.

We can improve this process by using hysteresis thresholding.

Page 2: Canny Edge Detector

October 9, 2014 Computer Vision Lecture 10: Edge Detection III

2

Canny Edge Detector

Hysteresis thresholding uses two thresholds - a low threshold L and a high threshold H.

Typically, H is chosen so that 2L H 3L.

In the first stage, we label each pixel in E[i, j] as follows:

• If E[i, j] > H then the pixel is an edge,

• If E[i, j] < L then the pixel is no edge (deleted),

• Otherwise, the pixel is an edge candidate.

Page 3: Canny Edge Detector

October 9, 2014 Computer Vision Lecture 10: Edge Detection III

3

Canny Edge Detector

In the second stage, we check for each edge candidate c whether it is connected to an edge via other candidates (8-neighborhood).

If so, we turn c into an edge.

Otherwise, we delete c, i.e., it is no edge.

This method fills gaps in contours and discards isolated edges that are unlikely to be part of any contour.

Page 4: Canny Edge Detector

October 9, 2014 Computer Vision Lecture 10: Edge Detection III

4

Canny Edge Detector - Example

Let us look at the following (already smoothed) sample image and perform Canny edge detection on it:

grayscale image

587577978579

691198490105100

82100101121165176

7187119182202211

101131180200215209

78120170183219220

intensity values of same image

Page 5: Canny Edge Detector

October 9, 2014 Computer Vision Lecture 10: Edge Detection III

5

Canny Edge Detector - Example

Applying the vertical and horizontal gradient filters gives us the following results:

Q[i, j]

000000

0-33.516.5-13-1.55.5

0-34-17-13-29.5-3

0-17-16.5-41.5-32-10

0-23-40.5-41.5-17.5-1.5

0-36-49.5-16.5-252

P[i, j]

000000

0-27.5-25.50-6.5-20.5

031-24-45.5-68

012-2.5-39.5-49-36

0-37-52.5-39.5-15.5-5.5

01710.513.57-7

Page 6: Canny Edge Detector

October 9, 2014 Computer Vision Lecture 10: Edge Detection III

6

Canny Edge Detector - Example

Based on P[i, j] and Q[i, j], we can now compute the magnitude and orientation of the gradient:

m[i, j]

000000

043.330.4136.721.2

034.11727.354.268.1

020.816.757.358.537.4

043.666.357.323.45.7

039.850.621.3267.3

[i, j]

000000

0231147270193165

0 27587208213183

0305261226213196

0212218226228195

0295282309286164

Page 7: Canny Edge Detector

October 9, 2014 Computer Vision Lecture 10: Edge Detection III

7

Canny Edge Detector - Example

This allows us to compute the sector [i, j] for each gradient angle [i, j]:

[i, j]

000000

013200

022110

032110

011110

032320 Remember the directions:

103

2[i,j]2

301

Page 8: Canny Edge Detector

October 9, 2014 Computer Vision Lecture 10: Edge Detection III

8

Canny Edge Detector - Example

Next step: nonmaxima suppression:

E[i, j]

043.30000

034.10000

020.80054.268.1

00057.358.50

0066.357.300

0050.60267.3

Page 9: Canny Edge Detector

October 9, 2014 Computer Vision Lecture 10: Edge Detection III

9

Canny Edge Detector - Example

Finally: hysteresis thresholding (L = 30, H = 60):

Hysteresis stage 2:1 = edge; 0 = no edge;

000000

000000

000011

000110

001100

001000

Hysteresis stage 1:1 = edge; 0 = no edge;? = edge candidate

0?0000

0?0000

0000?1

000??0

001?00

00?000

Page 10: Canny Edge Detector

October 9, 2014 Computer Vision Lecture 10: Edge Detection III

10

Canny Edge Detector - Example

Finally we visualize the detected edge pixels (0 = black, 1 = white) and indicate the precise edge locations (the pixels’ lower right corners) in the original image:

edge locations in original image

edge pixels

Page 11: Canny Edge Detector

October 9, 2014 Computer Vision Lecture 10: Edge Detection III

11

Evaluating Edge Detector Performance

How can we decide which type of edge detector we should use in our application?

For this purpose, we need to find a method for evaluating the performance of these detectors.

First of all, we need to create one of more test images for which we know the actual locations and orientations of edges.

A straightforward idea is to just draw an image showing geometric objects.

One possible measure for edge detector performance is called the figure of merit.

Page 12: Canny Edge Detector

October 9, 2014 Computer Vision Lecture 10: Edge Detection III

12

Evaluating Edge Detector Performance

The figure of merit FM is computed as follows:

with

number of detected edges IA,

number of ideal edges II,

distance between the actual and ideal edges (as matched by an appropriate algorithm) d, and

constant for penalizing displaced edges .

AI

i iIA dIIFM

121

1

),max(

1

Page 13: Canny Edge Detector

October 9, 2014 Computer Vision Lecture 10: Edge Detection III

13

Evaluating Edge Detector Performance

The maximum value of FM is 1, which indicates perfect performance.

The closer FM is to 0, the poorer the performance.

Of course even a poor edge detector can perform very well in artificial images that show, for example, only perfect rectangles.

In order to perform a more meaningful analysis, we should add noise to our test images and see how well our edge detector can handle it.

One possibility is to simulate varying degrees of Gaussian noise in our test images.

Page 14: Canny Edge Detector

October 9, 2014 Computer Vision Lecture 10: Edge Detection III

14

Simulating Gaussian NoiseIn order to simulate Gaussian noise, change the intensity of each pixel according to a Gaussian random distribution:

prob

abili

ty

intensityoriginal intensity i of pixel

Probability for new intensity i’ of pixel

standard deviation of Gaussian determines amount of noise

Page 15: Canny Edge Detector

October 9, 2014 Computer Vision Lecture 10: Edge Detection III

15

Simulating Gaussian NoiseTo simulate a Gaussian random distribution, keep on choosing 2D random points in the marked rectangular area until one of them is under the Gaussian curve. Set i’ to the horizontal coordinate of that point.

prob

abili

ty

intensityoriginal intensity i of pixel

new intensity i’

Page 16: Canny Edge Detector

October 9, 2014 Computer Vision Lecture 10: Edge Detection III

16

Evaluating Edge Detector PerformanceWe can then measure the figure of merit as a function of the Gaussian noise added to the input image:

of Gaussian noise

figur

e of

mer

it

1

00 10050

strong (robust) edge detector

weak edge detector