Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

Computing a skeleton

First, we declare some operators.

    CMMFile File
    CAlgebre algebre
    CCAlgebre calgebre
    CBasic basic
    CMorpho6c Morpho6c
    CMorpho4c Morpho4c
    CMorpho8c Morpho8c
Then, we create a Tcl proc for computing the skeleton. The idea is to use the skeleton_anchor with as anchor points the maxima of the distance function. We are going to write a procedure which has as argument the connectivity. The default is 6c, the 6-connectivity.
    proc skeleton {img {con 6c}} {
Then compute the distance
            CImageGrey dist -this [Morpho$con chamfer [$img cget -this]]
Take the maxima that are included in the object.
            CImageGrey max1 -this [Morpho$con localMaximum [dist cget -this]]
            CImageGrey max -this [algebre mult [max1 cget -this] [$img cget -this]]
Then compute the skeleton
            CImageGrey skel -this [Morpho$con skeleton_anchor [$img cget -this] [max cget -this]]
and stretch the image so that we can see the results
            CImageGrey resskel$con -this [basic stretch [skel cget -this]]
and write the results on the disk
            File PGMWrite [resskel$con cget -this] skeleton$con.pgm
Then free the memory
            deletePtr dist
            deletePtr max
            deletePtr max1
            deletePtr resskel$con
            deletePtr skel
    }
We will compute the skeleton on an image
    CImageGrey img -this [File PGMRead shape2.pgm]
and compute the skeleton
    skeleton img 6c

Generated at Sun May 12 19:04:30 2002 for OpenMorpho by doxygen1.2.0 written by Dimitri van Heesch, © 1997-2000