You are on page 1of 5

Edge Detection Method

The First Derivative - Gradient: The gradient method detects the edges by looking for the maximum and minimum in the first derivative of the image. The Second Derivatives - Laplacian: The Laplacian method searches for zero crossings in the second derivative of the image to find edges. An edge has the one-dimensional shape of a ramp and calculating the derivative of the image can highlight its location.

Deteksi Tepi Canny


Yeni Herdiyeni Departemen Ilmu Komputer IPB

Canny Edge Detector

Canny Edge Detector

Canny Edge Detector

Canny Edge Detector

Deteksi Tepi (edge)


Perubahan mencapai maksimum pada saat nilai turunannya pertamanya mencapai nilai maksimum atau nilai turunan kedua (2nd derivative) bernilai 0.

The Canny edge detector

original image (Lena)


5

The Canny edge detector

The Canny edge detector

Gradient magnitude

thresholding

The Canny edge detector


Steps

Canny Edge Detection


1. Doing Convolution :Apply derivative of Gaussian (to compute Gradient Magnitude) 2. Non-maximum suppression
Thin multi-pixel wide ridges down to single pixel Low, high edge-strength thresholds Accept all edges over low threshold that are connected to edge over high threshold

3. Thresholding

thinning (non-maximum suppression)

Matlab: edge(I, canny)

Gradient
At each point convolve with
Gx 1 1 1 1

Detecting Edges in Image


1 1
*

Gy

1 1

Sobel Edge Detector


1 0 2 0 1 0 1 2 1

Sobel also can be applied to compute gradient magnitude and orientation of the Gradient are computed as

d I dx
d I dx

d I dy

Edges Threshold

M [i, j ]
[i, j ]

P[i, j ]

Q[i, j ]

Image I
*

tan 1 (Q[i, j ], P[i, j ])


Canny Edge Detector 11

1 0 1

2 0 2

1 0 1

Avoid floating point arithmetic for fast computation

d I dy

Teknik Konvolusi

Example: Non-Maximum Suppression

courtesy of G. Loy

Original image

Gradient magnitude

Non-maxima suppressed

Canny Edge Detector

13

Edge Smearing
Input

Non-Maxima Suppression
Thin edges by keeping large values of Gradient
not always at the location of an edge there are many thick edges 0 0 0 0 1 1 1 0 0 0 1 2 1 3 0 0 2 1 2 1 1 0 1 3 2 1 1 0 0 3 2 1 0 0 1 2 3 2 0 0 1 0 2 3 2 0 1 0 2
Canny Edge Detector

0 0 0 0 0 0 0 0

0 0 0 0 6 8 8 6

2 2 2 2 6 8 8 6

2 2 2 2 0 0 0 0

2 2 2 2 -6 -8 -8 -6

3 1 0 0 0 1 1
16

Result

from Forsyth & Ponce

Sobel filter example: Yields 2-pixel wide edge band

We want to localize the edge to within 1 pixel

Non-Maxima Suppression (2)


Thin the broad ridges in M[i,j] into ridges that are only one pixel wide Find local maxima in M[i,j] by suppressing all values along the line of the Gradient that are not peak values of the ridge
0 3 0 0 0 0 1 3 3 3 0 0 2 3 2 2 2 0 1 1 2 1 0 0 1 2 2 1 0 0 1 1 1 1 1 0 1 0 1 3 1 0 1 0 2 3 1 0 0 3 1 1
17

Edge Streaking
Can predict next pixel in edge orthogonal to gradient to make edge chain
Can also just use 8-connectedness to define chains

Streaking: Gaps in edge chain due to edge strength gap dipping below threshold

false edges

0 0 2 2

gaps
courtesy of G. Loy

Canny Edge Detector

Original image

Strong edges

Example: Canny Edge Detection


gap is gone

Non-Maximum Suppression
Suppress the pixels in Gradient Magnitude Image which are not local maximum
M x, y
x, y x ,y

Original image

Strong + connected weak edges

S x, y 0

if

S x, y

S x,y

x,y
Strong edges only
courtesy of G. Loy

& S x, y S x ,y otherwise

Weak edges

x ,y and x ,y are the neighbors of x,y in along the direction normal to an edge

Gradient Orientation
Reduce angle of Gradient [i,j] to one of the 4 sectors Check the 3x3 region of each M[i,j] If the value at the center is not greater than the 2 values along the gradient, then M[i,j] is set to 0

0 0 0 0 1 1 1 3
0 0 0 1 2 1 3 1 0 0 2 1 2 1 1 0 0 1 3 2 1 1 0 0 0 3 2 1 0 0 1 0 2 3 2 0 0 1 0 1 2 3 2 0 1 0 2 1

local maxima removed depends on condition

Canny Edge Detector

21

Canny Edge Detector

22

0 0 0 0 0 0 0

0 0 0 0 3 3 3

0 0 2 3 2 0 0

0 0 1 0 0 0 0

0 2 2 0 0 0 1

0 1 0 0 0 1 0

0 3 0 0 0 0 2

3 0 0 0 0 1 0

Thresholding
Reduce number of false edges by applying a threshold T
false edges

The suppressed magnitude image will contain many false edges caused by noise or fine texture
Canny Edge Detector 23

all values below T are changed to 0 selecting a good values for T is difficult some false edges will remain if T is too low some edges will disappear if T is too high some edges will disappear due to softening of the edge contrast by shadows
Canny Edge Detector 24

Double Thresholding
Apply two thresholds in the suppressed image
T2 = 2T2 two images in the output the image from T2 contains fewer edges but has gaps in the contours the image from T1 has many false edges combine the results from T1 and T2 link the edges of T2 into contours until we reach a gap link the edge from T2 with edge pixels from a T1 contour until a T2 edge is found again
Canny Edge Detector 25

T2=2
0 0 0 0 0 0 0 3 0 0 0 0 2 0 3 0 0 0 2 0 2 0 0 0

T1=1
0 0 0 0 0 0 0 3 0 0 0 0 2 1 3 0 0 0 2 1 2 0 0 0 0 0 3 0 0 0 0 0 0 3 2 0 0 0 0 0 0 3 0 0 0 1 0 1 0 3 0 0 1 0 2 0

gaps 0 0 3 0 0 0 0 0 filled 0 3 2 0 0 0 0 0 from T1


0 3 0 0 0 0 0 0 0 3 0 0 0 0 2 0

A T2 contour has pixels along the green arrows Linking: search in a 3x3 of each pixel and connect the pixel at the center with the one having greater value Search in the direction of the edge (direction of Gradient)
Canny Edge Detector 26

Line Detection
Model of a line: two edges with opposite polarity in distance less than the size of the smoothing filter
edge detection filters respond to step edges they do not provide meaningful response to lines

Tugas
Buat program deteksi tepi Canny menggunakan matlab, tidak boleh menggunakan fungsi dari matlab : edge(I, canny) Sertakan penjelasan teori dan kode programnya pada laporan terpisah dengan kode program (*baca referensi yang diberikan) Tugas dikumpulkan tgl 4 Desember 2009
27 Canny Edge Detector 28

Apply nonmaxima suppression on the smoothed output


a line is the derivative of a step the derivative step of the Canny algorithm is not necessary
Canny Edge Detector