First, we declare some operators.
CMMFile File CAlgebre algebre CCAlgebre calgebre CBasic basic CMorpho6c Morpho6c CMorpho4c Morpho4c CMorpho8c Morpho8c
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}} {
CImageGrey dist -this [Morpho$con chamfer [$img cget -this]]
CImageGrey max1 -this [Morpho$con localMaximum [dist cget -this]] CImageGrey max -this [algebre mult [max1 cget -this] [$img cget -this]]
CImageGrey skel -this [Morpho$con skeleton_anchor [$img cget -this] [max cget -this]]
CImageGrey resskel$con -this [basic stretch [skel cget -this]]
File PGMWrite [resskel$con cget -this] skeleton$con.pgm
deletePtr dist deletePtr max deletePtr max1 deletePtr resskel$con deletePtr skel }
CImageGrey img -this [File PGMRead shape2.pgm]
skeleton img 6c