03 edgedet slides

Upload: jean-carlos-gonzalez-hernandez

Post on 05-Apr-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 03 Edgedet Slides

    1/24

    Basic image processing: edge detection

    http://find/http://goback/
  • 8/2/2019 03 Edgedet Slides

    2/24

    Edge detection problem

    Edge detection is sometimes an abused notion in image processing. Partof the complication lies in the difficulty in defining precisely what ismeant by an edge. A set of different examples of edges are shown below:

    http://find/
  • 8/2/2019 03 Edgedet Slides

    3/24

    Gradient-based methods

    Gradient-based methods are often used to find edges in images. Consider

    for example a 1-D function f(x) the derivative

    f(x) =df

    dx

    takes on values with a large magnitude at the points where the function

    has a high rate of change. It is reasonable to expect that these pointswill correspond to edges in the function.

    The generalisation of f(x) to a 2-D function f(x, y) is the gradient

    f(x, y) =f(x, y)

    x

    ix +f(x, y)

    y

    iy,

    where ix and iy are unit vectors in the x and y directions respectively.The magnitude off(x, y) is first computed, and is then compared to athreshold to find candidate edge points.

    http://find/
  • 8/2/2019 03 Edgedet Slides

    4/24

    Nondirectional edge detector

    An edge detection system based on a function such as |f(x, y)| is calleda nondirectional edge detector, since such functions favour no particulardirection. However, if for example we use |f(x, y)/x| instead of|f(x, y)| then one obtains a directional edge detector, which in thiscase only detects edges in the vertical direction and does not respond tohorizontal edges.

    For a 2-D sequence f(n1, n2), the partial derivatives may be replaced by adiscrete approximation such as

    f(x, y)

    x [f(n1, n2) f(n1 1, n2)]/T

    orf(x, y)

    x [f(n1 + 1, n2) f(n1 1, n2)]/(2T).

    http://find/
  • 8/2/2019 03 Edgedet Slides

    5/24

  • 8/2/2019 03 Edgedet Slides

    6/24

    Horizontal gradient example

    An example of an image and the estimated horizontal derivative is shownbelow:

    50 100 150 200 250

    50

    100

    150

    200

    250

    50 100 150 200 250

    50

    100

    150

    200

    250

    http://find/http://goback/
  • 8/2/2019 03 Edgedet Slides

    7/24

    Noise reduction

    Derivatives calculated using the method described are typically quitenoisy estimates off(x, y)/x. This can be improved by averaging the

    derivative over several samples, for example

    f(x, y)

    x [f(n1 + 1, n2 + 1) f(n1 1, n2 + 1)]

    + [f(n1 + 1, n2) f(n1 1, n2)]

    + [f(n1 + 1, n2 1) f(n1 1, n2 1)].

    This is equivalent to calculating the horizontal derivative by convolvingwith the kernel

    0

    +1 1

    +1

    +1

    1

    1

    0

    0

    http://find/
  • 8/2/2019 03 Edgedet Slides

    8/24

    Horizontal gradient reduced noise

    An example of applying this process to the previous image is shown

    below:

    50 100 150 200 250

    50

    100

    150

    200

    250

    http://find/
  • 8/2/2019 03 Edgedet Slides

    9/24

  • 8/2/2019 03 Edgedet Slides

    10/24

    Standard edge detectors

    Examples of common filters for detecting edges in the vertical andhorizontal direction are

    Roberts:

    h1 =

    0 11 0

    , h2 =

    1 00 1

    .

    Prewitt:

    h1 =1 0 11 0 11 0 1

    , h2 = 1 1 10 0 01 1 1

    . Sobel:

    h1 =1 0 12 0 21 0 1

    , h2 = 1 2 10 0 01 2 1

    .In these relationships h1 corresponds to a filter for detecting horizontaledges, and h2 vertical edges. The formulations differ in terms of their

    properties, and in some cases their computational complexity.

    http://find/
  • 8/2/2019 03 Edgedet Slides

    11/24

    Nondirectional edge detectors

    Nondirectional edge detectors can be developed using a discreteapproximation to |f(x, y)|, such as

    |f(x, y)| =

    f(x, y)x

    2+

    f(x, y)y

    2.

    Clearly this just involves forming some combination of the edges in thehorizontal and vertical directions.

    http://find/
  • 8/2/2019 03 Edgedet Slides

    12/24

    Laplacian-based methods

    The objective of an edge detection algorithm is to locate regions wherethe intensity is changing rapidly. For 1-D functions and gradient-basedmethods, f(x) is considered large when its magnitude |f(x)| is largerthan a threshold. Another way is to assume |f(x)| large whenever it

    reaches a local extremum, or when f

    (x) has a zero crossing.Declaring zero-crossing points as edges results in a large number ofpoints being declared edge points. Since the magnitude of f(x) is notconsidered, any small ripple in f(x, y) generates a detected edge. Due tothis sensitivity to noise, the application of noise reduction is a necessary

    prerequisite.

    http://find/http://goback/
  • 8/2/2019 03 Edgedet Slides

    13/24

    Estimating the Laplacian

    A generalisation of2f(x)/x2 to a 2-D function f(x, y) for purposes ofedge detection is the Laplacian

    2f(x, y) = (f(x, y)) = 2f(x, y)x2

    + 2f(x, y)y2

    .

    For a 2-D sequence f(n1, n2) the partial derivatives can be replaced bysome form of second-order differences. As in the case of gradient-based

    methods, these differences can be represented by a convolution off(n1, n2) with the impulse response of a filter h(n1, n2). For example,approximating the derivative by

    f(x, y)

    x fx(n1, n2) = f(n1 + 1, n2) f(n1, n2),

    the term 2f(x, y)/x2 can be approximated by

    2f(x, y)

    x2 fxx(n1, n2) = fx(n1, n2) fx(n1 1, n2)

    = f(n1 + 1, n2) 2f(n1, n2) + f(n1 1, n2).

    http://find/http://goback/
  • 8/2/2019 03 Edgedet Slides

    14/24

    Estimating the Laplacian (2)

    With the derivatives in the y-direction approximated similarly, theestimate of the Laplacian is

    2f(x, y) fxx(n1, n2) + fyy(n1, n2)

    = f(n1 + 1, n2) + f(n1 1, n2) + f(n1, n2 + 1)

    + f(n1, n2 1) 4f(n1, n2).

    http://goforward/http://find/http://goback/
  • 8/2/2019 03 Edgedet Slides

    15/24

    Laplacian edge detector example

    An estimate of the Laplacian for the image shown previously is

    50 100 150 200 250

    50

    100

    150

    200

    250

    Locating edges now involves finding zero crossings of this function.

    L l

    http://find/http://goback/
  • 8/2/2019 03 Edgedet Slides

    16/24

    Laplacian operators

    Some examples of discrete Laplace operators are

    h = 0 1 01 4 1

    0 1 0

    , h = 1 1 11 8 11 1 1

    .

    P i f d

    http://find/
  • 8/2/2019 03 Edgedet Slides

    17/24

    Perception of edges

    Do you think that either of the two methods presented coincide with theway we perceive edges?

    Ed li ki

    http://find/http://goback/
  • 8/2/2019 03 Edgedet Slides

    18/24

    Edge linking

    Obtaining an estimate of the image gradient is only part of the problemin edge detection, where the final goal is a binary image indicating thepresence of edges. There are many different ways of linking regions ofhigh gradient into distinct edges.

    http://find/http://goback/
  • 8/2/2019 03 Edgedet Slides

    19/24

  • 8/2/2019 03 Edgedet Slides

    20/24

  • 8/2/2019 03 Edgedet Slides

    21/24

    E ample Bottles (2)

  • 8/2/2019 03 Edgedet Slides

    22/24

    Example: Bottles (2)

    Estimates of the vertical and horizontal edge gradients are shown below:

    Example: Bottles (3)

    http://find/http://goback/
  • 8/2/2019 03 Edgedet Slides

    23/24

    Example: Bottles (3)

    Standard methods for locating the circular rim of the bottle were applied,and an edge direction mask of the following form was applied to theresulting edge estimates:

    http://find/http://goback/
  • 8/2/2019 03 Edgedet Slides

    24/24