Hi Juan, I don't understand the option "mask" in implemented in *skimage.morphology.medial.axis()*. I supposed that mask set as a square structuring element would yield a "thick" skeleton.When applied on a test image (top green), the medial_axis with two kinds of mask (middle top) yield the same results (red). These results can be compared with mahotas.thin() (top left) or skimage.morpholgy.skeletonize() (top right). The branched points are overlaid on their skeleton (down). <https://lh3.googleusercontent.com/-rTKvmWQfn9g/U5G9ypm34jI/AAAAAAAAB2U/Q2TxC...>
The code is: se8 = np.array([[True,True,True], [True,True,True], [True,True,True]]) se4 = np.array([[False,True,False], [True,True,True], [False,True,False]]) imK = makeLetterImage('a', 80) skel0 = morphology.medial_axis(imK,mask=se8) skel1= morphology.medial_axis(imK,mask=se4) skel2 = morphology.skeletonize(imK) skel = mh.thin(imK) Ep_Bp, Bp_Bp, Bp, Ep = SkeletonDecomposition(skel) BP1 = branchedPoints(skel1) BP2 = branchedPoints(skel2) figsize(15,10) subplot(241,xticks=[],yticks=[]) title('mahotas thin') imshow(skel+1*imK, interpolation='nearest') subplot(242,xticks=[],yticks=[]) title('skimage medial axis se8') imshow(skel0+1*imK, interpolation='nearest') subplot(243,xticks=[],yticks=[]) title('skimage medial axis se4') imshow(skel1+1*imK, interpolation='nearest') subplot(244,xticks=[],yticks=[]) title('skimage skeletonize') imshow(skel2+1*imK, interpolation='nearest') subplot(245,xticks=[],yticks=[]) title('maho thin()+branched-points') imshow(skel+1*Bp, interpolation='nearest') subplot(246,xticks=[],yticks=[]) title('sk medial axis+branched-points') imshow(skel1+1*BP1, interpolation='nearest') subplot(248,xticks=[],yticks=[]) title('skeletonize+branched-points') imshow(skel2+1*BP2, interpolation='nearest') The complete code is in an ipython notebook (joined). Thanks Jean-Patrick Le jeudi 5 juin 2014 14:24:02 UTC+2, Jean-Patrick Pommier a écrit :
Hi, Is it possible to skeletonize a binary 2D shape such that its skeleton is defined on a neighbourhood of 8 pixels?
When skeletonizing with : *morphology.medial_axis()* , I tried two structuring elements (se8 or se4) as mask :
se8 = np.array([[True,True,True],[True,True,True],[True,True,True]]) se4 = np.array([[False,True,False],[True,True,True],[False,True,False]])
imK = makeLetterImage('K', 70) skel = *morphology.medial_axis*(imK,mask=se8) Ep_Bp, Bp_Bp, Bp, Ep = SkeletonDecomposition(skel)
The skeletons returned using se8 or se4 are very similar and look defined on a neighbourhood of 4 pixels (left). To me, this is a problem when trying to label the skeleton edges (right).
<https://lh4.googleusercontent.com/-curcY_g5N9A/U5BfJdpe6yI/AAAAAAAAB0w/1PbxF...>
Jean-Patrick
<https://lh4.googleusercontent.com/-curcY_g5N9A/U5BfJdpe6yI/AAAAAAAAB0w/1PbxF...>