Making algorithms at least 3D, preferably nD

Juan Nunez-Iglesias jni.soma at gmail.com
Fri Apr 26 11:23:01 EDT 2013


On Fri, Apr 26, 2013 at 2:36 PM, Stéfan van der Walt <stefan at sun.ac.za>wrote:

> Juan's the right guy for the job!


Oh *great*. #bus #thrownunder

=P


>  I read his original email again,
> and while I agree that supporting N-d is important, it still strikes
> me as a lot harder to implement something in N-d vs 2-D (it's much
> more than just grabbing the "juicy center", etc.).


It depends a lot on the algorithm. For many (all the ones I've used,
anyway), the algorithm works on voxels (is it hypervoxels in nD? =) and
their neighbours, so you just need to abstract away the "neighbour"
concept. See my (pure python, slow as molasses) watershed implementation
here <https://github.com/janelia-flyem/gala/blob/master/gala/morpho.py#L168>,
which depends on the function `get_neighbor_idxs`
here<https://github.com/janelia-flyem/gala/blob/master/gala/morpho.py#L460>.
(Full
disclosure: it's so slow that when the parameters are right, it falls back
on skimage. ;)

I don't think any of these functions are in principle difficult to
implement in Cython, so long as you pass the raveled array+shape, rather
than the full n-dimensional array. It just wasn't a priority after you guys
came out with 3D watershed. =)

SLIC is another easy one to make nD: rather than 2D+RGB, it could be
nD+arbitrary channels. The algorithm is exactly the same. (Sorry I've been
slow on that one. Again: would have been easier to be nD from the start,
rather than converting Andy's implementation which is a headache simply
because it assumes 2D+3 channels in so many places.)

At any rate, I've slightly softened my stance. The reason is that all these
neighbourhood models implicitly assume that the data are isotropic, ie same
resolution along each dimension. This is possible, even probable, until 3
dimensions, and essentially impossible in 4D or higher. So while it's cute
and nice to make it nD, realistically, 3D is good enough for most purposes.
And you can't argue that it's much harder to do 3D than 2D. =)

Regarding tutorials, what exactly are people looking for? I incidentally
have zero experience with:
1. writing tutorials,
2. mayavi, or
3. cross-correlation methods.

However, I'm very much interested in learning about 1 and 2, so I'm happy
to take this on with a bit of guidance! (But I have no helpful suggestions
for Marianne's specific problem... Sorry!)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20130426/18f94905/attachment.html>


More information about the scikit-image mailing list