The actual implementation of the medial axis is transformed?

I have seen many explanations of what the algorithm is based on, but I can’t find any real code (pseudocode or in some language) of the medial axis itself.

In some cases (for example, polygons with discrete angles) it can be simplified into a triangle triangle, but I'm more interested in the case when you have a blob (for example, a tracked person) and you want to calculate its skeleton.

What will the pseudo code look like for this?

+5
source share
1 answer

Hereyou have code from pymorph library:

Primarily:

def mmskelm(f, B=None, option="binary"):
    from string import upper
    from Numeric import asarray
    if B is None: B = mmsecross()
    assert mmisbinary(f),'Input binary image only'
    option = upper(option)
    k1,k2 = mmlimits(f)
    y = mmgray(mmintersec(f, k1),'uint16')
    iszero = asarray(y)
    nb = mmsesum(B,0)
    for r in range(1,65535):
        ero = mmero( f, nb)
        if mmisequal(ero, iszero): break
        f1 = mmopenth( ero, B)
        nb = mmsedil(nb, B)
        y = mmunion(y, mmgray(f1,'uint16',r))
    if option == 'BINARY':
        y = mmbinary(y)
    return y

, .

Mathematica

enter image description here

!

+5

All Articles