kuliah 10 deteksi tepi canny edit print

5

Click here to load reader

Upload: adhy-rhx-hacker

Post on 19-Oct-2015

12 views

Category:

Documents


1 download

DESCRIPTION

deteksi tepi canny

TRANSCRIPT

  • 1Deteksi Tepi Canny

    Yeni Herdiyeni

    Departemen Ilmu Komputer IPB

    Canny Edge Detector 1

    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.

    Canny Edge Detector 2

    Canny Edge Detector 3 Canny Edge Detector 4

    Deteksi Tepi (edge)

    Perubahan mencapai maksimum pada

    saat nilai turunannya pertamanya

    mencapai nilai maksimum atau nilai

    turunan kedua (2nd derivative) bernilai

    0.

    5

    The Canny edge detector

    original image (Lena)

  • 2The Canny edge detector

    Gradient magnitude

    The Canny edge detector

    thresholding

    The Canny edge detector

    thinning

    (non-maximum suppression)

    Canny Edge Detection

    Steps

    1. Doing Convolution :Apply derivative of Gaussian (to

    compute Gradient Magnitude)

    2. Non-maximum suppression

    Thin multi-pixel wide ridges down to single pixel

    3. Thresholding

    Low, high edge-strength thresholds

    Accept all edges over low threshold that are connected to edge

    over high threshold

    Matlab: edge(I, canny)

    Canny Edge Detector 11

    Gradient

    At each point convolve with

    Sobel also can be applied to compute gradient

    magnitude and orientation of the Gradient are computed as

    Avoid floating point arithmetic for fast computation

    11

    11xG

    11

    11yG

    22 ],[],[],[ jiQjiPjiM

    ]),[],,[(tan],[ 1 jiPjiQji

    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

  • 3Teknik Konvolusi

    Canny Edge Detector 13

    Example:

    Non-Maximum Suppression

    courtesy of G. Loy

    Original image Gradient magnitudeNon-maxima suppressed

    Edge Smearing

    from Forsyth & Ponce

    0

    0

    0

    0

    2

    2

    2

    2

    20

    20

    20

    20

    2

    2

    2

    2

    Sobel filter example: Yields2-pixel wide edge band

    We want to localize the edge to within 1 pixel

    6

    8

    8

    6

    6

    8

    8

    6

    00

    00

    00

    00

    -8

    -6

    -6

    -8

    Input

    Result

    Canny Edge Detector 16

    Non-Maxima Suppression

    Thin edges by keeping large values of Gradient

    not always at the location of an edge

    there are many thick edges

    12010232

    10100232

    01001230

    00112310

    01121200

    13121000

    31110000

    Canny Edge Detector 17

    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

    12010232

    10100232

    31001230

    00112310

    01121200

    13121003

    31110000

    gaps

    false

    edges

    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 dipping below threshold

    courtesy of G. Loy

    Original image Strong edges

    gap

  • 4Example: Canny Edge Detection

    courtesy of G. Loy

    gap is gone

    Originalimage

    Strongedges

    only

    Strong +connectedweak edges

    Weakedges

    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

    yxMyx ,

    yx,

    yx ,

    Canny Edge Detector 21

    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

    Canny Edge Detector 22

    local

    maxima

    removed

    depends

    on condition

    12010232

    10100232

    01001230

    00112310

    01121200

    13121000

    31110000

    Canny Edge Detector 23

    The suppressed magnitude image will contain many

    false edges caused by noise or fine texture

    02010030

    10100030

    00000230

    00000300

    00021200

    03120000

    30000000

    false edges

    Canny Edge Detector 24

    Thresholding

    Reduce number of false edges by applying a

    threshold T

    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

  • 5Canny Edge Detector 25

    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 26

    T2=2 T1=1

    02000030

    00000030

    00000230

    00000300

    00020200

    03020000

    30000000

    02010030

    10100030

    00000230

    00000300

    00021200

    03120000

    30000000

    gaps

    filled

    from

    T1

    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 27

    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

    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

    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

    Canny Edge Detector 28