BasicComp Vison

download BasicComp Vison

of 52

Transcript of BasicComp Vison

  • 7/21/2019 BasicComp Vison

    1/52

    Einfhrung in die Erweiterte Realitt

    8. Basic Computer Vision

    Dec 21, 2004

    Prof. Gudrun Klinker, Ph.D.

    Institut fr Informatik,Technische Universitt Mnchen

    [email protected]

  • 7/21/2019 BasicComp Vison

    2/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 2

    Reference

    R. Jain, R. Kasturi, and B. Schunk.Machine Vision,McGraw Hill, 1995, ISBN 0-07-032018-7

  • 7/21/2019 BasicComp Vison

    3/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 3

    Overview

    Image Formation (Geometry, Radiometry) Feature Detection

    Region(Similarity)-based Approaches

    Edge(Difference)-based Approaches

    Feature Matching and Tracking

  • 7/21/2019 BasicComp Vison

    4/52Dec 21, 2004Introduction to AR8. Basic Computer Vision 4

    1. Image Formation

    Image geometry (Image radiometry)

  • 7/21/2019 BasicComp Vison

    5/52Dec 21, 2004

    Introduction to AR8. Basic Computer Vision 5

    Image Geometry - Pinhole Projection -

    y

    z

    f

    r

    r

    Object point

    (x,y,z)

    (x,y)

    xy

    Image plane

    (inverted)

    z

    xx

    y

  • 7/21/2019 BasicComp Vison

    6/52Dec 21, 2004

    Introduction to AR8. Basic Computer Vision 6

    Image Geometry - Pinhole Projection -

    y

    z

    fr

    Object point

    (x,y,z)

    (x,y)

    xy

    x

    Image plane

    x

    r

    y

  • 7/21/2019 BasicComp Vison

    7/52Dec 21, 2004

    Introduction to AR8. Basic Computer Vision 7

    Image Geometry

    Image arrayy

    Image plane

    (x,y)

    0 column j m-1

    row ipixel a[i,j]

    0.

    .

    .

    .

    n-1

    x = j - m2- 1

    y = - (i - n2- 1)

    x

  • 7/21/2019 BasicComp Vison

    8/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 8

    Image Radiometry - Basic -

    Color pixel [i,j] = {R,G,B} or {R,G,B,}

    Graypixel [i,j] = {I}

    HSI color representation

    cos (Hue) = (2R - G - B) / (2 (R-G)2) + (R-G)(G-B) )

    Saturation = 1 - 3/(R+G+B) * min (R,G,B)

    Intensity = (R+G+B)/3

    Common practice (for fast processing)

    I = R or I = G

    HueSatur

    ation

  • 7/21/2019 BasicComp Vison

    9/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 9

    Overview

    Image Formation (Geometry, Radiometry) Feature Detection

    Region(Similarity)-based Approaches

    Edge(Difference)-based Approaches

    Feature Matching and Tracking

  • 7/21/2019 BasicComp Vison

    10/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 10

    Overview: Region-based Approaches

    Thresholding, Histograms Connected Components

    Region Boundaries

    Region Properties

    Morphological Operations

  • 7/21/2019 BasicComp Vison

    11/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 11

    Thresholding f B[i,j] = Lookup tables fB[i,j] = lookup [fA[i,j]]

    x

    I(x)

    0, if fA[i,j] < t

    1, if fA[i,j] > t

    t1

    t2

    2. Image Thresholding

  • 7/21/2019 BasicComp Vison

    12/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 12

    2.1 Histogram-based Region Segmentation

    P-tile method Mode method

    Iterative threshold selection

    Adaptive, variable thresholding

    Double thresholdingI

    h(I)

    0 0 0 1 1 0 0 1 00 0 0 1 1 0 1 1 0

    1 1 1 1 1 1 1 1 0

    0 1 1 1 1 1 0 0 00 0 0 1 1 0 1 1 0

  • 7/21/2019 BasicComp Vison

    13/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 13

    2.2 Connected Component Analysis -Pixel Neighborhoods-

    4-neighbors

    8-neighbors

    4-path, 8-path

    Connected components 8 4

    Background and holes 4 8

    Boundary

    0 1 0

    1 1 10 1 0

    1 1 1

    1 1 11 1 1

    0 1 0

    1 0 10 1 0

    0 1 0

    1 0 10 1 0

    0 0 0 1 1 0 0 1 00 0 0 1 1 0 1 1 0

    1 1 1 1 1 1 1 1 0

    0 1 1 1 1 1 0 0 0

    0 0 0 1 1 0 1 1 0

  • 7/21/2019 BasicComp Vison

    14/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 14

    Connected Component Analysis - Algorithms -

    Two-pass approach progressingin row-major order

    Recursive region growing

    find seed

    check each neighborthat hasnt been visited yet

    if neighbor is inside the region, label it

    recurse

    0 0 0 1 1 0 0 1 0

    0 0 0 1 1 0 1 1 0

    1 1 1 1 1 1 1 1 0

    0 1 1 1 1 1 0 0 0

    0 0 0 1 1 0 2 2 0

  • 7/21/2019 BasicComp Vison

    15/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 15

    2.3 Region Boundary Detection

    Boundary pixel:A pixel that has 4-neighbors that dontbelong to the region.

    Crab algorithm to follow a region boundary: Find starting boundary pixel

    Set starting search direction

    Find next boundary pixel

    Reset starting search direction Shape fitting (ellipsoid, polygon, )

    0 0 0 1 1 0 0 1 0

    0 0 0 1 1 0 1 1 0

    1 1 1 1 1 1 1 1 00 1 1 1 1 1 0 0 0

    0 0 0 1 1 0 2 2 0

    1

    2 3 4

    5

    678

  • 7/21/2019 BasicComp Vison

    16/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 16

    2.4 Region Properties

    Area A and perimeter P Compactness

    Relationship between A and P

    Boundary (Chain Code)

    2 3 4

    1 x 5

    8 7 6

  • 7/21/2019 BasicComp Vison

    17/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 17

    Region Properties - Geometric (Moments) -

    Size (zeroth

    -order moment)A = B[i,j]

    Position (first-order moments)

    mi = i B[i,j] / Amj = j B[i,j] / A

    Orientation (second-order moments)a = (I- m

    i)2 B[i,j]

    b = 2 (I- mi)(j- mj) B[i,j]c = (j- mj)

    2 B[i,j]tan 2 = b / (a-c)

    0 0 0 1 1 0 0 1 0

    0 0 0 1 1 0 1 1 0

    1 1 1 1 1 1 1 1 0

    0 1 1 1 1 0 0 0 0

    0 0 0 1 1 0 1 1 0

  • 7/21/2019 BasicComp Vison

    18/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 18

    Region Properties - Photometric -

    Photometric Properties of a Region Mean intensity (color)

    Intensity variation

    (color variation: 3 eigenvectors) Repetitive patterns (textures)

  • 7/21/2019 BasicComp Vison

    19/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 19

    2.5 Morphological Operators on Region Masks

    Intersection of two masks Union of two masks

    Complement of a mask

    Dilation of a mask by a structuring element (simple case:region expansion)

    Erosion (simple case: region shrinking)

    Opening: erosion + dilation Closing: dilation + erosion

  • 7/21/2019 BasicComp Vison

    20/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 20

    Overview

    Image Formation (Geometry, Radiometry) Feature Detection

    Region(Similarity)-based Approaches

    Edge(Difference)-based Approaches

    Feature Matching and Tracking

  • 7/21/2019 BasicComp Vison

    21/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 21

    3. Edge Detection

    Maximal/MinimalImage Gradient

    (Optima in the1rst derivative)

    I(x)

    x

    x

    I(x)

  • 7/21/2019 BasicComp Vison

    22/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 22

    Edge Detection - Continuous Case -

    Image gradient (first derivative of f(x,y))

    orientation (direction of steepest ascent) (x,y) = tan-1 (Gy / Gx)

    magnitude||G[f(x,y)]|| = (Gx2 + Gy

    2)~ || Gx || + || Gy ||

    G[f(x,y)] = =GxGy

    f

    x

    f

    y

    3 1 S

  • 7/21/2019 BasicComp Vison

    23/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 23

    3.1 Simple Edge Detectors -Discrete Approximations-

    1 0

    0 -1

    0 -1

    1 0 Roberts Cross

    Sobel

    Prewitt

    -1 0 1

    -2 0 2

    -1 0 1

    1 2 1

    0 0 0-1 -2 -1

    -1 0 1

    -1 0 1-1 0 1

    1 1 1

    0 0 0-1 -1 -1

    Si l Ed D t t Th L l i

  • 7/21/2019 BasicComp Vison

    24/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 24

    Simple Edge Detectors -The Laplacian (2nd Derivative)-

    Optima of 1. derivative of f(x,y)Zero-crossings of 2. derivative of f(x,y)

    Problem: very sensitive to noise!

    2f = +2f

    x2

    0 1 0

    1 -4 1

    0 1 0

    2f

    y2

    = f[i,j+1] - 2f[i,j] + f[i,j-1]2f

    x2

    2

    fy2 = f[i+1,j] - 2f[i,j] + f[i-1,j]

    1 4 1

    4 -20 4

    1 4 1

    3 2 I C l ti

  • 7/21/2019 BasicComp Vison

    25/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 25

    3.2 Image Convolution

    h(x,y) = f(x,y) * g(x,y)

    = f(x + x, y + y) g(x, y) dx dy

    h [i,j] = f [i - n/2 +k, j - n/2 +l] g[k, l]

    - -

    k=0

    n-1

    l=0

    m-1

    Di t I C l ti

  • 7/21/2019 BasicComp Vison

    26/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 26

    Discrete Image Convolution

    h [i,j] = f [i - n/2 +k, j - n/2 +l] g[k, l]k=0

    n-1

    l=0

    m-1

    i

    jinput image f(i,j)

    convolution mask

    g(k,l)

    3 3 Res lt Edgels

  • 7/21/2019 BasicComp Vison

    27/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 27

    3.3 Result: Edgels

    Edgel: pixelwise indicator of local edge strength dominant edge direction

    Edgels

  • 7/21/2019 BasicComp Vison

    28/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 28

    Edgels

    Local clusters of edgels along unsharp edgesI(x)

    xI(x)

    x

    3 4 Robust Edge Detection

  • 7/21/2019 BasicComp Vison

    29/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 29

    3.4 Robust Edge Detection

    Detection problems (classification errors) Lack of acuracy (position, orientation)

    False edges (false positives)

    Missing edges (false negatives)

    Combined filters for Smoothing (noise reduction)

    Enhancement (edge detection)

    Detection (magnitude thresholding)

    [Localization (subpixel precision)]

    3 4 1 Smoothing Filters

  • 7/21/2019 BasicComp Vison

    30/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 30

    3.4.1 Smoothing Filters

    Local pixel averages

    Gaussian low-pass filter

    1 1 1

    1 1 11 1 1

    * 1/9

    1 2 1

    2 4 2

    1 2 1

    * 1/16

    g[k,l] = e- (k2+l2)

    22with

    k: -n/2 .. n/2

    l: -m/2 .. m/2

    1 1 2 2 2 1 11 2 2 4 2 2 1

    2 2 4 8 4 2 2

    2 4 8 16 8 4 2

    2 2 4 8 4 2 2

    1 2 2 4 2 2 11 1 2 2 2 1 1

    * 1 / 144

    3 4 2 Enhancement

  • 7/21/2019 BasicComp Vison

    31/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 31

    3.4.2 Enhancement

    Gradient-based edge detection Second derivative

    3 4 3 Detection

  • 7/21/2019 BasicComp Vison

    32/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 32

    3.4.3 Detection

    Thinning of edgel clusters: Determination of local

    maxima along the

    dominant edge

    direction

    Computation ofzero-crossings in

    the 2nd derivative

    3 4 4 Example: Mexican Hat Operator

  • 7/21/2019 BasicComp Vison

    33/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 33

    3.4.4 Example: Mexican Hat Operator

    Laplacian of Gaussian (LoG) Smoothing with a Gaussian filter

    Enhancement by 2. derivative edge detection

    Detection of zero crossings in 2. derivative incombination with large peak in 1. derivative

    Localization with subpixel precision using linear

    interpolation

  • 7/21/2019 BasicComp Vison

    34/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 34

    LoG-Operatorh(x,y) =2[g(x,y) * f(x,y)]

    = [2g(x,y)] * f(x,y)0 0 -1 0 0

    0 -1 -2 -1 0

    -1 -2 16 -2 -1

    0 -1 -2 -1 0

    0 0 -1 0 0

    0 0 0 0 0 0 -1 -1 -1 -1 -1 0 0 0 0 0 0

    0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0

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

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

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

    0 -1 -2 -3 -3 -3 0 2 4 2 0 -3 -3 -3 -2 -1 0

    -1 -1 -3 -3 -3 0 4 10 12 10 4 0 -3 -3 -3 -1 -1

    -1 -1 -3 -3 -2 2 10 18 21 18 10 2 -2 -3 -3 -1 -1

    -1 -1 -3 -3 -3 4 12 21 24 21 12 4 -3 -3 -3 -1 -1

    -1 -1 -3 -3 -2 2 10 18 21 18 10 2 -2 -3 -3 -1 -1

    -1 -1 -3 -3 -3 0 4 10 12 10 4 0 -3 -3 -3 -1 -1

    0 -1 -2 -3 -3 -3 0 2 4 2 0 -3 -3 -3 -2 -1 0

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

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

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

    0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0

    0 0 0 0 0 0 -1 -1 -1 -1 -1 0 0 0 0 0 0

    3 4 5 Example: Canny Edge Detector

  • 7/21/2019 BasicComp Vison

    35/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 35

    3.4.5 Example: Canny Edge Detector

    First derivative of a Gaussian(sensitive in the direction of steepest change,insensitive along edge)

    Nonmaxima suppression (ridge thinning) Double thresholding to detect and link edges

    S[i,j] = G[i,j;] I[i,j]

    P[i,j] = - S[i,j] + S[i,j+1]

    - S[i+1,j] + S[i+1,j+1]Q[i,j] = S[i,j] + S[i,j+1]

    - S[i+1,j] - S[i+1,j+1]

    -1 1

    -1 1

    1 1

    -1 -1

    3.5 Shape Fitting

  • 7/21/2019 BasicComp Vison

    36/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 36

    3.5 Shape Fitting

    Determination of consistant groupsof edgels (clustering)

    Robust estimation of shape

    parameters (least squares,

    disregarding outliers)

    Shape Fitting - Quality Criteria -

  • 7/21/2019 BasicComp Vison

    37/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 37

    Shape Fitting Quality Criteria

    Goodness of fit Maximum absolute error

    Mean squared error

    Normalized maximum error Number of sign changes

    Ratio of curve length to end point distance

    Shape Fitting - Models -

  • 7/21/2019 BasicComp Vison

    38/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 38

    S ape g ode s

    Line segments (Polylines) Circular arcs

    Conic sections

    Cubic splines

    Polylines

  • 7/21/2019 BasicComp Vison

    39/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 39

    y

    Sequence of line segments implicit line representation f(x,y) = 0 distance from line -> f(x,y) = d

    Polyline splitting (recursive subdivision)

    Segment merging (bottom-up approach)

    Split and merge

    Overview

  • 7/21/2019 BasicComp Vison

    40/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 40

    Image Formation (Geometry, Radiometry) Feature Detection

    Region(Similarity)-based Approaches

    Edge(Difference)-based Approaches

    Feature Matching and Tracking

    4. Feature Matching (3D to 2D)

  • 7/21/2019 BasicComp Vison

    41/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 41

    g ( )

    Photometric (Colors) Color constancy problems: changing illumination, shadowing, Invariant to changing image resolution / object size

    Geometric (Shapes) One object at a time (unique recognition): Geometric invariants

    under 3D transformations and projections

    Groups of objects in combination (graph matching)

    Feature Matching (2D to 2D)

  • 7/21/2019 BasicComp Vison

    42/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 42

    g ( )

    Init: known feature positions in Image1..i-1 Loop: (real-time)

    Predict approximate position of each feature in Imagei Search local image areas for features

    Handle exceptions: Disappearing feature

    Partially visible feature

    Reappearing feature

    Update feature motion models

    Compute 3D interpretation Continue loop

    Example: - Target Detection and Identification -

  • 7/21/2019 BasicComp Vison

    43/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 43

    Find dark blobs onbright background

    Fit quadrilateral

    polygons Find corners

    Read ID label

    2D Motion Estimation

  • 7/21/2019 BasicComp Vison

    44/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 44

    Compute local motionvectors of everyfeature (images n-1,

    n-2) (more images to

    estimate higher-

    order motion models)

    2D Motion Prediction

  • 7/21/2019 BasicComp Vison

    45/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 45

    Prediction of localfeature motion forimage n

    Target Redetection

  • 7/21/2019 BasicComp Vison

    46/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 46

    Prediction of localfeature motion forimage n

    Other 2D Matching Techniques - Cross Correlation -

  • 7/21/2019 BasicComp Vison

    47/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 47

    unnormalized:r(i,j) = {t(x,y) * s(i+x,j+y)}

    normalized:

    {[t(x,y)-T]*[s(i+x,j+y)-Sij]}

    x,y

    r(i,j) =

    [t(x,y) - T]2 * [s(i+x,j+y) - Sij]2

    Image 1 Image 2

    search region s

    mean Sij (i,j)

    i

    j

    template t,mean T

    Other 2D Matching Techniques - Gradient-Based Image Flow -

  • 7/21/2019 BasicComp Vison

    48/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 48

    Velocity field in the image plane due to the motion of theobserver, objects or apparent motion

    t+1tI(x,t)

    I(x1,t+1)

    I(x1,t)

    dx

    u = dx =I(x1,t) - I(x1,t+1)

    || image gradient ||v = dy = ...

    x1 x2 x

    Gradient-Based Image Flow

  • 7/21/2019 BasicComp Vison

    49/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 49

    Aperture problem

    Two variables (u,v) per pixel; only one constraint

    I[x,y,t]

    flow[u,v]=

    flow[dx/dt,dy/dt]

    Gradient-Based Image Flow

  • 7/21/2019 BasicComp Vison

    50/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 50

    Smoothness assumption:The velocity field varies smoothly over an image.

    u = uaverage - Ix

    v = vaverage - Iy

    P = Ix uaverage + Iy vaverage + It

    D = 2

    + Ix2

    + Iy2

    PD

    P

    D

    Gradient-Based Image Flow

  • 7/21/2019 BasicComp Vison

    51/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 51

    Variational calculus Image-flow constraint flow(x,y,t):Exu + Eyv + Et = 0

    Smoothness constraint:

    Minimize:

    u u v vx y x v

    2

    +

    2

    +

    2

    +

    2

    dx dysm(x,y,t) =

    (flow(x,y,t) + smoothness(x,y,t)) dx dy2 2

  • 7/21/2019 BasicComp Vison

    52/52

    Dec 21, 2004Introduction to AR8. Basic Computer Vision 52