edge metalab by sanmelody

VIEWS: 18 PAGES: 68

									Chapter 2: Image Analysis



            Edge and Line
            Detection
Edge/Line Detection

   There are various types of operators that can
    be used to perform edge/line detection.
   Many edge/line detection operators are
    implemented with convolution mask.
   The concept behind edge detection is to
    measure the rate of change in brightness.
Edge/Line Detection

   A large change of brightness over a short spatial
    distance indicates the presence of an edge.
   Edge detection operators return information
    regarding the edge magnitude.
    –   A larger change in brightness would return a higher edge
        magnitude.
   Some edge detection operators even return
    information regarding the direction of the edge.
Edge/Line Detection

   The output of an edge detection process can
    be visualized in two ways:
    –   Using a binary image where the edges are
        highlighted in white (1) and everything else in
        black (0).
    –   Using a gray level image where the edges are
        highlighted using white color of varying
        brightness. Edges with higher magnitude will
        produce brighter white.
Edge/Line Detection
Edge/Line Detection

   Before edge detection is performed, some
    pre-processing may need to be done.
   For example, the existence of noise can
    create problems in performing edge
    detection.
   It is best to preprocess an image to
    eliminate/minimize noise effects using mean
    or median filters.
Edge/Line Detection
Edge/Line Detection
Edge/Line Detection

   When dealing with noise, there is a tradeoff between
    the sensitivity and the accuracy of an edge detector.
   Sensitivity refers to how easy it is for the edge
    detector to detect edges.
    –   A sensitive edge detector can detect edges more easily.
   Making an edge detector too sensitive or less
    sensitive has its own pros and cons.
    –   If an edge detector is too sensitive, it may return many edge
        points which are noise.
    –   If it is less sensitive, it may miss valid edges.
Edge/Line Detection

   The sensitivity of an edge detection operator
    depends on:
    –   Size of the edge detection mask.
    –   The value of the gray-level threshold.
   Mask size:
    –   A larger mask size makes the edge detector less sensitive.
   Value of gray-level threshold:
    –   A higher threshold makes the edge detector less sensitive.
Roberts Operator

   Mark edge points only; does not return any
    information about edge orientation.
   The simplest operator and work best with
    binary images.
   There are two forms of Roberts operator.
    –   Square root of the sum of the difference of the
        diagonal neighbors squared.
Robert Operators

     –   The sum of the magnitude of the differences
         of the diagonal neighbors.



   The second form is often used in practice
    due to its computational efficiency.
    –    It is typically faster for a computer to find an
         absolute value than to find square roots.
Sobel Operator

   Look for edges in both the horizontal and
    vertical directions and then combine this
    information into a single metric.
Sobel Operator

   Each of the masks are convolved with the
    image.
   At each pixel location, there will now be two
    numbers:
    –   s1: corresponding to the result from row mask.
    –   s2: corresponding to the result from column mask.
   These two numbers are then used to
    compute the edge magnitude and direction.
Sobel Operator

                    The edge direction is
                     defined as the degree
                     from the vertical axis in
                     clockwise direction.


                              θ
Prewitt Operator

   Similar to the Sobel operator, except that it
    has different mask coefficients.
Prewitt Operator

   Each of the masks is convolved with the
    image.
   At each pixel location, there will now be two
    numbers:
    –   p1: corresponding to the result from row mask.
    –   p2: corresponding to the result from column mask.
   These two numbers are then used to
    compute the edge magnitude and direction.
Prewitt Operator

                      The edge direction is
                       defined as the degree
                       from the vertical axis in
                       clockwise direction.



                                  θ
Kirsch Compass Masks

   The masks are defined by taking a single
    mask, and rotating it to eight major compass
    direction
    –   North, Northwest, West, Southwest, South,
        Southeast, East, and Northeast.
   The masks are defined as follows:
Kirsch Compass Masks
Kirsch Compass Masks

   The edge magnitude is defined as the
    maximum value found by the convolution of
    each of the masks with the image.
   The edge direction is defined by the mask
    that produces the maximum magnitude. For
    example:
    –   Mask K0 corresponds to a vertical edge.
    –   Mask K5 corresponds to a diagonal edge in the
        northwest/southeast direction.
Robinson Compass Mask

   Used in a similar manner to the Kirsch
    masks, but are easier to implement.
    –   Only has coefficients of 0, 1 and 2.
    –   Symmetrical about their directional axis – the axis
        with zeros.
   Only need to compute the result on four of
    the masks. The results of the other four can
    be obtained by negating the first four results.
Robinson Compass Masks
Robinson Compass Masks

   The edge magnitude and direction are
    defined in the same way as in Kirsch masks.
   Notice that r0 and r6 are the same as the
    Sobel masks.
   Actually, any of the edge detection masks
    can be extended by rotating them in a
    manner similar to these compass masks.
    –   Example: One may rotate Prewitt operator.
Laplacian Operators

   The laplacian masks are rotationally
    symmetric: edges at all direction contribute to
    the result.
   They are applied by selecting one mask and
    convolving it with the image.
   The sign of the result (positive or negative)
    from two adjacent pixel locations tells which
    side of the edge is brighter.
Laplacian Operators




   Notice that the laplacian masks here are different
    from the enhancement filters used in preprocessing.
    –   Center coefficient is decreased by one.
    –   Sum of the mask coefficients becomes zero.
    –   Does not retain original brightness, only return edge
        information.
Frei-Chen Masks

   They form a complete set of basis vectors.
    –   We can represent any 3x3 subimage as a
        weighted sum of the nine Frei-Chen masks.
   These weights are found by projecting a 3x3
    subimage onto each of these masks.
    –   The projection process is similar to convolution
        process.
    –   Overlay the mask on the image, multiply
        coincident terms and sum the results.
Frei-Chen Masks
Frei-Chen Masks
Frei-Chen Masks
Frei-Chen Masks

   One can reconstruct the image with the
    weight and also the masks.
   Take the weight, multiply with the masks and
    sum the corresponding values.
Frei-Chen Masks

   To use Frei-Chen masks for edge detection:
    –   Select a particular subspace of interest (horizontal
        edge, vertical edge, etc) and find the relative
        projection of the image onto the particular
        subspace.
   The advantage of this method is that we can
    select particular edge or line masks of
    interest and consider the projection of those
    masks only.
Frei-Chen Masks

                                 The set {e} consist of
              M
cos                             the marks of interest.
              S                  The (Is, fk) notation
                                  refers to the process
where                             of overlaying the
M      (I
      k{e}
              s,   fk )   2       mask on the
                                  subimage, multiplying
                                  the coincident terms
      9                           and summing the
S   (I s, f k )2                results (a vector inner
     k 1                         product).
Frei-Chen Masks

   The output of Frei-Chen Masks operation is a
    theta (θ) value.
    –   This value ranges from 0 to 90 degree.
   This value acts like an edge magnitude.
    –   Smaller theta (θ) corresponds to higher
        magnitude.
Edge Operator Performance

   To evaluate the performance of different
    edge detection operators, we need to use
    both objective and subjective evaluation.
    –   Objective evaluation: measure using fixed
        analytical methods.
    –   Subjective evaluation: let human view the image.
Edge Operator Performance

   In order to develop a performance metric for
    edge detector, we need to define:
    –   What constitutes success.
    –   What types of errors can occur.
   The types of errors are:
    –   Missing valid edge points.
    –   Classifying noise pulses as valid edge points.
    –   Smeared edges.
Edge Operator Performance
Edge Operator Performance
Edge Operator Performance

One metric called Pratt Figure of Merit Rating
Factor is define as follow:
                  IF
          I               1
      R
         IN
                  1  d
                 i 1
                              2


IN = the maximum of II and IF
II = the number of ideal edge points in the image
IF = the number of edge points found by the edge detector
 = a scaling constant that can be adjusted to adjust the
penalty for offset edges
d = the distance of a found edge point to an ideal edge point
Edge Operator Performance

   For this metric, R will be 1 for a perfect edge.
   In general, this metric assigns a better rating
    to smeared edges than to offset or missing
    edges.
   This is done because there exist techniques
    to thin smeared edges, but it is difficult to
    determine when an edge is missed.
Edge Operator Performance

   The objective metrics are often of limited use
    in practical applications.
   The subjective evaluation by human visual
    system is still superior than any computer
    vision system.
Edge Operator Performance
Edge Operator Performance
Edge Operator Performance
Edge Operator Performance
Edge Operator Performance

   All operators return almost similar results
    except the laplacian operators.
    –   Laplacian returns positive and negative numbers
        that get linearly remapped to 0 to 255.
    –   The background value of 0 is mapped to some
        intermediate gray level.
   Only the magnitude is used for displaying the
    results.
Edge Operator Performance

   If we add noise to the image, the results are
    not as good.
   There are a number of ways to solve this:
    –   Preprocess the image with spatial filters to
        remove the noise.
    –   Expand the edge detection operators.
Edge Operator Performance

1 1 1 0 1 1 1        1 1 1  2 1 1 1
1 1 1 0 1 1 1        1 1 1  2 1 1 1
1 1 1 0 1 1 1        1 1 1  2 1 1 1
1 1 1 0 1 1 1        0   0    0    0    0   0    0
1 1 1 0 1 1 1        1   1    1    2    1   1    1
1 1 1 0 1 1 1        1   1    1    2    1   1    1
1 1 1 0 1 1 1        1   1    1    2    1   1    1
Extended Prewitt Edge   Extended Sobel Edge Detection
Detection Mask          Mask
Edge Operator Performance

   We can also define    1 1 1 0   1   1 1
    a truncated pyramid   1 2 2 0  2  2 1
    operator.
                          1 2 3 0  3  2 1
   This operator
                          1 2 3 0  3  2 1
    provides weights
    that decrease as we   1 2 3 0  3  2 1
    get away from the     1 2 2 0  2  2 1
    center pixel.         1 1 1 0   1   1 1
Edge Operator Performance
Edge Operator Performance
Edge Operator Performance
Edge Operator Performance
Edge Operator Performance

   On images with noise, the extended
    operators exhibit better performance than the
    3x3 masks.
   However, they have a number of setbacks:
    –   Requires more computation.
    –   Tends to slightly blur the edges.
Hough Transform

   Hough transform is used to find lines.
   A line is defined as a collection of edge
    points that are adjacent and have the same
    direction.
   Hough transform will take a collection of
    edge points found by an edge detector, and
    find all the lines on which these edge points
    lie.
Hough Transform

   In order to understand Hough transform,
    consider the normal (perpendicular)
    representation of a line:
    –   ρ = r cos θ + c sin θ
   Each pair of ρ and θ corresponds to a
    possible line equation.
    –   The range of θ is  90o
    –   The range of ρ is from 0 to 2N (N is image size)
Hough Transform
Hough Transform

   A line is a path where points that lie on it
    have the same direction (share the same line
    equation).
   The idea is to find the number of points that
    lie in each possible line within an image
    plane.
   The line that accommodates the most points
    shall be the candidate line.
Hough Transform

   However, in practical, there tend to be many
    lines.
    –   Therefore, in practice, a line is selected if the
        number of points that lie on it is more than certain
        threshold (user-defined).
   We cannot have infinite precision for ρ and θ
    or we will have infinite line equations.
    –   Therefore, we need to quantize the ρθ parameter
        space.
Hough Transform
Hough Transform

   Each block in the quantized space
    corresponds to a line, or group of possible
    lines.
   The algorithm used for Hough Transform
    consists of three primary steps:
    –   Define the desired increments on ρ and θ, Δρ and
        Δθ, and quantize the space accordingly.
Hough Transform

 –   For every point of interest (edge points), plug the
     values for r and c into the line equation:
       ρ = r cos θ + c sin θ
     Then, for each value of θ in the quantized space,
     solve for ρ.
 –   For each ρθ pair from step 2, record the rc pair in
     the corresponding block in the quantized space.
     This constitutes a hit for that particular block.
Hough Transform

   When this process is completed, the number
    of hits in each block corresponds to the
    number of pixels on the line as defined by
    the values ρ and θ in that block.
   Next, select a threshold and select the
    quantization blocks that contain more points
    than the threshold.
Hough Transform

   When this process is completed, the lines are
    marked in the output image.
   There is a tradeoff in choosing the size of the
    quantization blocks:
    –   Large blocks will reduce search time.
    –   However, it may reduce the line resolution in the
        image space.
Hough Transform
Hough Transform
Hough Transform
Hough Transform

								
To top