I have seen plenty of explanations of what the algorithm is based on, but I can not seem to find any actual code (pseudocode or in some language) of the medial axis transform itself.
For certain instances (such as polygons with discrete corners), it can be simplified into a delaunay triangle, but I am more concerned with the case that you have a blob (such as a human being tracked) and want to compute its skeleton.
What would the pseudocode for this look like?
Here
you have the code from the pymorph library
:
It's basically:
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
Of course it uses another functions from the same package.
An example from Mathematica
HTH!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With