Lec-5 Image Analysis-Boundary Detection

Embed Size (px)

Citation preview

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    1/77

    1

    Image Analysis

    Boundary Detection

    Dr. Ziya Telatar

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    2/77

    Image Analysis

    Feature Extraction

    - Spatial Features

    - Transform Features

    - Edges and

    Boundaries- Shape Features

    - Moments

    - Texture

    Segmentation

    - Template Matching

    - Thresholding

    - Boundary

    Detection

    - Clustering

    - Quad-Trees

    - Texture matching

    Classification

    - Clustering

    - Statistical

    - Decision Trees

    - Similarity Measures

    - Min. Spanning

    Trees

    IMAGE ANALYSIS TECHNIQUES

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    3/77

    Image Analysis Preview

    Feature extraxtion is the first and importantstep for succesfully analysis

    Segmentation is to subdivide an image into

    its constituent regions or objects. Segmentation should stop when the objectsof interest in an application have beenisolated.

    Classification is closely related tosegmentation

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    4/77

    Principal approaches

    Segmentation based feature extractionalgorithms generally are based on one of 2

    basis properties of intensity values discontinuity : to partition an image based on

    abrupt changes in intensity (such as edges)

    similarity : to partition an image into regions

    that are similar according to a setof predefined criteria.

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    5/77

    Detection of Discontinuities

    detect the three basic types of gray-level

    discontinuities

    points , lines , edges

    the common way is to run a mask through

    the image

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    6/77

    Point Detection

    a point has been detected at the location on

    which the mark is centered if

    |R| T

    where

    T is a nonnegative threshold

    R is the sum of products of the coefficients with

    the gray levels contained in the region

    encompassed by the mark.

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    7/77

    Point Detection

    Note that the mark is the same as the mask

    of Laplacian Operation

    The only differences that are considered of

    interest are those large enough (as

    determined by T) to be considered isolated

    points.|R| T

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    8/77

    Example

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    9/77

    Line Detection

    Horizontal mask will result with max response when a linepassed through the middle row of the mask with aconstant background.

    the similar idea is used with other masks.

    note: the preferred direction of each mask is weighted witha larger coefficient (i.e.,2) than other possible directions.

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    10/77

    Line Detection

    Apply every masks on the image

    let R1, R2, R3, R4 denotes the response of

    the horizontal, +45 degree, vertical and -45degree masks, respectively.

    if, at a certain point in the image

    |Ri| > |Rj|, for all ji, that point is said to be more likely

    associated with a line in the direction of maski.

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    11/77

    Line Detection

    Alternatively, if we are interested in detectingall lines in an image in the direction defined

    by a given mask, we simply run the maskthrough the image and threshold the absolutevalue of the result.

    The points that are left are the strongestresponses, which, for lines one pixel thick,correspond closest to the direction defined bythe mask.

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    12/77

    Example

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    13/77

    Edge Detection

    the most common approach for detecting

    meaningful discontinuities in gray level.

    we discuss approaches for implementing

    first-order derivative (Gradient operator)

    second-order derivative (Laplacian operator)

    Here, we will talk only about their properties

    for edge detection.

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    14/77

    Basic Formulation

    an edge is a set of connected pixels that

    lie on the boundary between two regions.

    an edge is a local concept whereas a

    region boundary, owing to the way it is

    defined, is a more global idea.

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    15/77

    Ideal and Ramp Edges

    because of optics,sampling, imageacquisitionimperfection

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    16/77

    Thick edge

    The slope of the ramp is inversely proportional to thedegree of blurring in the edge.

    We no longer have a thin (one pixel thick) path.

    Instead, an edge point now is any point contained in theramp, and an edge would then be a set of such points thatare connected.

    The thickness is determined by the length of the ramp.

    The length is determined by the slope, which is in turndetermined by the degree of blurring.

    Blurred edges tend to be thick and sharp edges tendto be thin

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    17/77

    First and Second derivatives

    the signs of the derivativeswould be reversed for an edgethat transitions from light to

    dark

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    18/77

    Second derivatives

    produces 2 values for every edge in animage (an undesirable feature)

    an imaginary straight line joining the

    extreme positive and negative values ofthe second derivative would cross zeronear the midpoint of the edge. (zero-crossing property)

    quite useful for locating the centers of thickedges

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    19/77

    Noisy Images

    First column: images andgray-level profiles of aramp edge corrupted byrandom Gaussian noiseof mean 0 and = 0.0,

    0.1, 1.0 and 10.0,respectively.

    Second column: first-derivative images andgray-level profiles.

    Third column : second-derivative images andgray-level profiles.

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    20/77

    Keep in mind

    fairly little noise can have such a

    significant impact on the two key

    derivatives used for edge detection in

    images

    image smoothing should be serious

    consideration prior to the use of

    derivatives in applications where noise islikely to be present.

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    21/77

    Edge point

    to determine a point as an edge point

    the transition in grey level associated with thepoint has to be significantly stronger than the

    background at that point. use threshold to determine whether a value is

    significant or not.

    the points two-dimensional first-order

    derivative must be greater than a specifiedthreshold.

    f

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    22/77

    Gradient Operator

    first derivatives are implemented using

    the magnitude of the gradient.

    y

    fx

    f

    G

    G

    y

    xf

    21

    22

    21

    22 ][)f(

    yf

    xf

    GGmagf yx

    the magnitude becomes nonlinearyx GGf

    commonly approx.

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    23/77

    Gradient direction

    Let (x,y) represent the direction angle of

    the vector f at (x,y)

    (x,y) = tan-1(Gy/Gx)

    The direction of an edge at (x,y) is

    perpendicular to the direction of the

    gradient vector at that point

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    24/77

    Gradient Masks

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    25/77

    Diagonal edges with Prewitt

    and Sobel masks

    Sobel masks haveslightly superiornoise-suppression

    characteristics whichis an important issuewhen dealing withderivatives.

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    26/77

    Example

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    27/77

    Example

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    28/77

    Example

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    29/77

    Laplacian

    2

    2

    2

    22 ),(),(

    y

    yxf

    x

    yxff

    (linear operator)

    Laplacian operator

    )],(4)1,()1,(

    ),1(),1([2

    yxfyxfyxf

    yxfyxff

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    30/77

    Laplacian of Gaussian

    Laplacian combined with smoothing as a

    precursor to find edges via zero-crossing.

    2

    2

    2

    )(

    r

    erh

    where r2= x2+y2, andis the standard deviation

    2

    2

    24

    222

    )(

    r

    er

    rh

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    31/77

    Mexican hat

    the coefficient must be sum to zero

    positive central term

    surrounded by an adjacent negative region (a function of distance)zero outer region

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    32/77

    Linear Operation

    second derivation is a linear operation

    thus, 2f is the same as convolving the

    image with Gaussian smoothing function

    first and then computing the Laplacian of

    the result

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    33/77

    Example

    a). Original imageb). Sobel Gradient

    c). Spatial Gaussiansmoothing functiond). Laplacian maske). LoG

    f). Threshold LoGg). Zero crossing

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    34/77

    Zero crossing & LoG

    Approximate the zero crossing from LoGimage

    to threshold the LoG image by setting all

    its positive values to white and all negativevalues to black.

    the zero crossing occur between positive

    and negative values of the thresholdedLoG.

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    35/77

    Zero crossing vs. Gradient

    Attractive

    Zero crossing produces thinner edges

    Noise reduction

    Drawbacks Zero crossing creates closed loops. (spaghetti

    effect)

    sophisticated computation.

    Gradient is more frequently used.

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    36/77

    Edge Linking and Grouping

    Define what it means for a group to be

    good.

    Usually this involves simplifications

    Search for the best group.

    Usually this is intractable, so short-cuts are

    needed.

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    37/77

    Parametric Grouping: Grouping

    Points into Lines

    Basic Facts about Lines

    (a,b)

    c (x,y) is on line if (x,y).(a,b) = cax + by = c

    Distance from (x,y) to line is

    (a,b).*(x,y) = ax + by

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    38/77

    Line Grouping Problem

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    39/77

    This is difficult because of:

    Extraneous data: Clutter

    Missing data

    Noise

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    40/77

    RANSAC: Random Sample

    Consensus

    Generate a bunch of reasonable

    hypotheses.

    Test to see which is the best.

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    41/77

    RANSAC for Lines Generate Lines using Pairs of Points

    How many samples?

    Supposep is fraction of points from line.

    npoints needed to define hypothesis (2 for lines)

    k samples chosen.

    Probability one sample correct is:

    kn

    p)1(1

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    42/77

    RANSAC for Lines: Continued

    Decide how good a line is:

    Count number of points within eof line.

    Parameteremeasures the amount of noise

    expected.

    Other possibilities. For example, for these

    points, also look at how far they are.

    Pick the best line.

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    43/77

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    44/77

    Some comparisons

    Complexity of RANSAC n*n*n

    Complexity of Hough n*d

    Error behavior: both can have problems,

    RANSAC perhaps easier to understand. Clutter: RANSAC very robust, Hough falls

    apart at some point.

    There are endless variations that improvesome of Houghs problems.

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    45/77

    Boundary Extraction

    Boundaries are linked edges that characterize

    the shape of an object

    Connectivity Boundaries can be found by tracing the connected

    edges

    On a rectangular grid, a pixel is said to be 4- or 8-

    connected when it has the same properties as one of

    its nearest 4 or 8 neighbors, respectively

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    46/77

    Neighbors of Pixels

    4- Neighborhood

    (x+1,y) (x-1,y) (x,y+1) (x,y-1)

    8- Neighbor with diagonal pixels

    (x+1,y+1) (x+1,y-1) (x-1,y+1) (x-1,y-1)

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    47/77

    Boundary Extraction

    Contour Following

    Contour-following algorithms trace boundaries by

    ordering successive edge points.

    Some example of algorithms are:

    Edge Linking and Hueristic Graph Search Dynamic programming

    Hough Transform

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    48/77

    Boundary Extraction

    Edge Linking:

    edge detection algorithm are followed by

    linking procedures to assemble edge pixels

    into meaningful edges.

    Basic approaches

    Local Processing

    Global Processing via the Hough Transform Global Processing via Graph-Theoretic

    Techniques

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    49/77

    Boundary Extraction

    Local Processing

    analyze the characteristics of pixels in a small

    neighborhood (say, 3x3, 5x5) about every

    edge pixels (x,y) in an image. all points that are similar according to a set of

    predefined criteria are linked, forming an edge

    of pixels that share those criteria.

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    50/77

    Boundary ExtractionLocal Processing

    Criteria

    1. the strength of the response of thegradient operator used to produce the

    edge pixel an edge pixel with coordinates (x0,y0) in a

    predefined neighborhood of (x,y) is similar inmagnitude to the pixel at (x,y) if

    |f(x,y) - f (x0,y0) | E

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    51/77

    Boundary ExtractionLocal Processing

    Criteria

    2. the direction of the gradient vector

    an edge pixel with coordinates (x0,y0) in a

    predefined neighborhood of (x,y) is similar in

    angle to the pixel at (x,y) if

    |(x,y) - (x0,y0) | < A

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    52/77

    Criteria

    A point in the predefined neighborhood of (x,y) is

    linked to the pixel at (x,y) if both magnitude

    and direction criteria are satified.

    the process is repeated at every location in theimage

    a record must be kept

    simply by assigning a different gray level to each

    set of linked edge pixels.

    fi d t l h i k

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    53/77

    Examplefind rectangles whose sizes makesthem suitable candidates for licenseplates

    use horizontal andvertical Sobel operators

    link conditions:gradient value > 25gradient direction differs < 15

    eliminate isolated shortsegments

    B d E t ti

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    54/77

    Boundary ExtractionHough Transformation (Line)

    yi=axi+ b b = - axi+ yi

    ab-plane or parameter space

    xy-plane

    all points (xi,yi) contained on the same line must have lines in

    parameter space that intersect at (a,b

    )

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    55/77

    Accumulator cells

    (amax, amin) and (bmax, bmin) are

    the expected ranges of slope

    and intercept values.

    all are initialized to zero

    if a choice of apresults in

    solution bqthen we let

    A(p,q) = A(p,q)+1

    at the end of the procedure,

    value Q in A(i,j) corresponds to

    Q points in the xy-plane lying

    on the line y = aix+bj b = - axi+ yi

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    56/77

    -plane

    problem of using equation y = ax + b is that value of a is infinite for avertical line.

    To avoid the problem, use equation x cos + y sin = to represent aline instead.

    vertical line has = 90with equals to the positive y-intercept or =

    -90with equals to the negative y-intercept

    x cos + y sin =

    -plane

    = 90 measured with respect to x-axis

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    57/77

    D2ofrange

    where D is the distancebetween corners in the

    image

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    58/77

    Generalized Hough Transformation

    can be used for any function of the form

    g(v,c) = 0

    v is a vector of coordinates

    c is a vector of coefficients

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    59/77

    Hough Transformation (Circle)

    equation:

    (x-c1)2+ (y-c2)

    2= c32

    three parameters (c1, c2, c3)

    cube like cells accumulators of the form A(i, j, k)

    increment c1and c2, solve of c3that satisfies theequation

    update the accumulator corresponding to thecell associated with triplet (c1, c2, c3)

    Edge linking based on Hough

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    60/77

    Edge-linking based on Hough

    Transformation

    1. Compute the gradient of an image andthreshold it to obtain a binary image.

    2. Specify subdivisions in the -plane.

    3. Examine the counts of the accumulatorcells for high pixel concentrations.

    4. Examine the relationship (principally for

    continuity) between pixels in a chosencell.

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    61/77

    The Hough Transform for

    Lines A line is the set of points (x, y) such that

    Different choices of , d>0 give different lines

    For any (x, y) there is a one parameter familyof lines through this point. Just let (x,y) be

    constants and , d be unknowns.

    Each point gets to vote for each line in the

    family; if there is a line that has lots of votes,

    that should be the line passing through the

    points

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    62/77

    Mechanics of the Hough

    transform Construct an arrayrepresenting , d

    For each point, render

    the curve (, d) into this

    array, adding one at

    each cell

    Difficulties

    how big should the cells

    be? (too big, and wecannot distinguish

    between quite different

    lines; too small, and

    noise causes lines to be

    missed)

    How many lines?

    count the peaks in the

    Hough array

    Who belongs to whichline?

    tag the votes

    Can modify voting, peak

    finding to reflect noise. Big problem if noise in

    Hough space different

    from noise in image

    space.

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    63/77

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    64/77

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    65/77

    Continuity

    based on computing the distance between

    disconnected pixels identified during

    traversal of the set of pixels corresponding

    to a given accumulator cell.

    a gap at any point is significant if the

    distance between that point and its closetneighbor exceeds a certain threshold.

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    66/77

    link criteria:1). the pixels belonged to one of the set of pixelslinked according to the highest count2). no gaps were longer than 5 pixels

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    67/77

    Boundary Representation

    Proper representation of object boundaries isimportant for analysis and synthesis of shape

    Shape analysis is often required for detection

    and recognition of objects in a scene.

    Shape synthesis is useful in computer-aideddesign (CAD) of parts and assemblies, image

    simulation applications such as video games,cartoon movies, environmental modeling ofaircraft-landing testing and training, etc.

    Methods for Boundary Representations

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    68/77

    Methods for Boundary Representations

    Chain Codes The direction vectors between successive boundary pixels are encoded.

    Fitting Line Segments Staright-line segments give simple approximation of curve boundaries.

    Approximate the curve by the line segment joining its end points.

    If the distance from the farthest curve point to the segment is greater than apredetermined quantitiy, join the points to line ends.

    B-Spline Representation Piecewise polynomial functions that can provide local approximations of contours

    of shapes using a small number of parameters.

    B-Splines are used in shape synthesis and analysis, computer graphics, andrecognition parts from boundaries.

    Fourier Descriptors Effect of Geometric Transformations

    Boundary matching from FD

    Autoregressive Models For arbitrary class of object boundaries, we have an ensemble of boundaries that

    could be represented by a stochastic model.

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    69/77

    Example:

    Boundary superimposed

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    70/77

    Region Representation

    The shape of an object may be directly

    represented by the region it occupies

    Run-length codes

    Quad-trees

    Projections

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    71/77

    Moment Representation

    The theory of moments provides an interestingand sometimes useful alternative to serious

    expansions for representing shape of objects

    Moment representation theorem Moment matching

    Orthogonal moments

    Moment invariants

    Translation Scaling

    Rotation and Reflection

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    72/77

    Structure

    In many computer vision applications, the objects in ascene can be characterized satisfactorily by structurescomposed of line or arc patterns like handwritten orprinted characters, circuit diagrams and engineeringdrawings, etc.

    Transformations useful for analysis of structure ofpatterns Medial Axes Transforms

    Skeleton Algorithms Thinning Algorithms

    Morphological Transforms

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    73/77

    Shape Features

    The shape of an object refers to its profile

    and physical structure

    These characteristics can be represented

    by the boundary, region, moment, and

    structural representations

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    74/77

    Shape Features

    Shape RepresentationRegenerative Features

    - Boundaries

    - Regions

    - Moments- Structural and Syntactic

    Measurement Features

    Geometry

    - Perimetry

    - Area

    - Max-min Radii

    and eccentricity

    - Corners

    - Roundness

    - Bending Energy

    - Holes

    - Euler Numbers

    - Symmetry

    Moments

    - Center of Mass

    - Orintation

    - Bounding

    Rectangle

    - Best-Fit Ellipse

    - Eccentricity

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    75/77

    Texture

    Texture is observed in the structural patterns of objectssuch as wood, grain, sand, grass, and cloth

    A texture contains several pixels, whose placementcould be periodic, quasi-periodic or random.

    Natural textures are generally random

    Artificial textures are often deterministic or periodic

    Texture are classified into two main categories:Statistical and Structural.

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    76/77

    TextureClassification of Texture

    Statistical

    - ACF (Autocorrelation

    Function)

    - Transforms

    - Edge-ness

    - Concurrence Matrix

    - TextureTransforms

    - Random Field

    Models

    Other

    Random

    - Edge Density

    - Extreme Density- Run Lengths

    Mosaic Models

    Structural

    Periodic

    - Primitives:

    - Gray Levels- Shape

    - Homogeneity

    - Placement Rules

    - Period

    - Adjacency

    - Closest

    Distances

  • 8/10/2019 Lec-5 Image Analysis-Boundary Detection

    77/77

    Scene Matching and Detection

    A problem of much significance in imageanalysis is the detection of change or presenceof an object in a given scene

    Methods Image Subtraction

    Template Matching and Area Correlation

    Matched Filtering

    Direct serch Two Dimensional Logarithmic search Sequential Search

    Hiearchical Search