jni / skan

Python module to analyse skeleton (thin object) images
https://skeleton-analysis.org
BSD 3-Clause "New" or "Revised" License
118 stars 39 forks source link

Suggestion for API: Return pixel_indices in different format #68

Open constantinpape opened 5 years ago

constantinpape commented 5 years ago

First of all, thanks a lot for skan. It makes my life much easier for an upcoming project involving quite a bit of skeleton analysis. I have a few minor pain points with the API though. The first one:

csr.skeleton_to_csgraph returns pixel_indices as np.array[n_skel_pix, n_dim] in float64. This can't be used to index the original image. I am using this to turn it into something that can index:

pixel_indices = tuple(pixel_indices[:, i].astype('uint64') for i in range(pixel_indices.shape[1]))

I am wondering if it wouldn't make sense to return this format by default. If this is not possible because downstream functionality depends on the output format, it might be nice to add a method to csr.Skeleton that wraps this.

jni commented 5 years ago

The thing is that it's actually subpixel coordinates... (Again, see supplementary material of the paper.) Perhaps I need to change the name of some variables... =P And perhaps a command-line flag could change this behaviour...

constantinpape commented 5 years ago

The thing is that it's actually _sub_pixel coordinates...

Ok, I will check out the paper. But just to clarify, for now the pixel_indices returned always correspond to the pixel position of the skeleton node, irrespective of the spacing parameter (at least that's the behaviour in 0.7.1)?!

And perhaps a command-line flag could change this behaviour...

Yes, I think that would be very useful for indexing.