Can a skeleton be defined on a neighbourhood of 8 pixels ?

Juan Nunez-Iglesias jni.soma at gmail.com
Tue Jun 10 20:13:38 EDT 2014


Hi Jean-Patrick,

I've just had a look at the code, and it seems you've misunderstood the
purpose of the `mask` keyword argument. This is not the morphological
structuring element, but a binary mask overlaying the entire image and
determining which pixels can and cannot be part of the skeleton. See the
relevant part of the code here:
https://github.com/scikit-image/scikit-image/blob/master/skimage/morphology/_skeletonize.py#L238

My intuition is that your calls should have resulted in some kind of
ValueError (since you are indexing an array with a boolean array of a
different shape), but evidently that's not true. We'll have to look into
updating the docs and maybe adding some input sanitising.

As to your broader question, I don't think it's possible with the current
codebase to do what you ask. We would need to update the lookup table
connectivity parameter, which is currently hardcoded here:
https://github.com/scikit-image/scikit-image/blob/master/skimage/morphology/_skeletonize.py#L235

Is there any reason why you can't just use Mahotas? =)

(Incidentally, the resolution on your characters is pretty low, which
explains the wonky skeletons... Thicker characters should produce more
regular skeletons, regardless of connectivity.)

Juan.


On Fri, Jun 6, 2014 at 11:59 PM, Jean-Patrick Pommier <
jeanpatrick.pommier at gmail.com> wrote:

> The ipython notebook is here
> <http://nbviewer.ipython.org/gist/jeanpat/da77a3b10c903f340d5c>
>
>
> 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/1PbxFHLHJ6s/s1600/labeling+edges.png>
>>
>> Jean-Patrick
>>
>> <https://lh4.googleusercontent.com/-curcY_g5N9A/U5BfJdpe6yI/AAAAAAAAB0w/1PbxFHLHJ6s/s1600/labeling+edges.png>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "scikit-image" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to scikit-image+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20140611/1f506f93/attachment.html>


More information about the scikit-image mailing list