MATLAB Shape Boundary

Embed Size (px)

Citation preview

  • 7/25/2019 MATLAB Shape Boundary

    1/13

    EE465: Introduction to Digital

    Ima e Processin

    1

    A MATLAB Tour ofBinary Image Analysis

  • 7/25/2019 MATLAB Shape Boundary

    2/13

    EE465: Introduction to Digital

    Ima e Processin

    Image Topology: Connectivitya and ! are connected if t"ere e#ists a $at" from a to !

    %o& do &e define t"e $at" for discrete images'

    4(neig"!ors)(neig"!ors

    De$ending on t"e selection of 4(neig"!ors or )(neig"!ors*

    &e mig"t "a+e different connecti+ity result

  • 7/25/2019 MATLAB Shape Boundary

    3/13

    EE465: Introduction to Digital

    Ima e Processin

    ,

    Example

    $

    -

    $ . - no matter

    4(neig"!ors or )(neig"!ors

    $

    -

    $ . - only &"en )(neig"!ors

    is considered

  • 7/25/2019 MATLAB Shape Boundary

    4/13

    EE465: Introduction to Digital

    Ima e Processin

    4

    Component Labeling

    If 4(neig"!ors*t"ree connected

    com$onents

    If )(neig"!ors*

    t&o connected

    com$onents

    original

    !inaryimage

  • 7/25/2019 MATLAB Shape Boundary

    5/13

    EE465: Introduction to Digital

    Ima e Processin

    5

    MATLAB Function BWLABEL /"el$ !&la!el B0LABEL La!el connected com$onents in !inary image L 2 B0LABEL3B0* returns a matri# L* of t"e same sie as B0* containing la!els for t"e connected com$onents in B0 can "a+e a +alue of eit"er 4 or )* &"ere 4 s$ecifies 4(connected o!7ects and ) s$ecifies )(connected o!7ects8 if t"e argument is omitted* it defaults to ) T"e elements of L are integer +alues greater t"an or e-ual to 9 T"e $i#els la!eled 9 are t"e !acground T"e $i#els la!eled 1 mae u$ one o!7ect* t"e $i#els la!eled mae u$ a second o!7ect* and so on

    ;L*

  • 7/25/2019 MATLAB Shape Boundary

    6/13

    EE465: Introduction to Digital

    Ima e Processin

    6

    Checkboar Image

    4(neig"!ors

    )(neig"!ors#

    Ims"o&3la!elrg!3!&la!el3#*4

    Ims"o&3la!elrg!3!&la!el3#*)

  • 7/25/2019 MATLAB Shape Boundary

    7/13

    EE465: Introduction to Digital

    Ima e Processin

    ?

    Euler !umber

    Euler um!er E2num!er of connected com$onents @ num!er of "oles

    E2(,E29

    E2(1

  • 7/25/2019 MATLAB Shape Boundary

    8/13

    EE465: Introduction to Digital

    Ima e Processin

    )

    Chain Coe"

    4(directional c"ain code:

    99,,,,,,,111191191

    )(directional c"ain code:

    9?666655,,11

  • 7/25/2019 MATLAB Shape Boundary

    9/13

    EE465: Introduction to Digital

    Ima e Processin

    MATLAB Implementation

  • 7/25/2019 MATLAB Shape Boundary

    10/13

    EE465: Introduction to Digital

    Ima e Processin

    19

    !ormali#ation $trategy

    ,,9911

    ,,9911

    ,9911,

    9911,,

    911,,911,,99

    1,,991

    ,,9911

    ,,9911

    >ortro&s

    9911,,

    911,,9

    11,,99

    1,,991,,9911

    ,,9911

    ,,9911

    ,9911,

    9911,,

    irst ro& gi+es t"e

    normalied c"ain code

    MATLAB function: sortro&s

  • 7/25/2019 MATLAB Shape Boundary

    11/13

    EE465: Introduction to Digital

    Ima e Processin

    11

    $hape !umber"% !ormali#e

    &i''erential Chain Coe"

    Differential code:

    d2c(c(13mod 4

    ,,9911

    191911,1

    ,,9191

    1911,119

    91911,11 91911,11

    differentiate

    normalie

    differentiate

    normalie

    MATLAB function: mod

  • 7/25/2019 MATLAB Shape Boundary

    12/13

    EE465: Introduction to Digital

    Ima e Processin

    1

    $keleton Fining via &i"tance

    Tran"'orm

    #

    !&dist3.#*Ccity!locC8 !&dist3#*Ccity!locC8

  • 7/25/2019 MATLAB Shape Boundary

    13/13

    EE465: Introduction to Digital

    Ima e Processin

    1,

    MATLAB Implementationfunction sk=skeleton_finding(x)

    % calculate distance transform

    dt=bwdist(~x,'cityblock');

    % find the local maximum

    n=! ";#" !;! #";" !$;

    sk=dt!;for i="&

    sk=sk(dt=circshift(dt,n(i,&)));

    end