Mamba3d and numpy

Skip to first unread message

Aug 16, 2014, 7:04:16 AM8/16/14
Is it possible to convert a 3d numpy array to a a mamba3D image?

Nicolas Beucher

Aug 17, 2014, 3:17:48 PM8/17/14

There is no reason for it not to be possible.
Here is an example of inyterfacing numpy and mamba for 2D images :

For 3D images you will have to proceed image by image by loading your 3D array by slices.


Mohammad Havaei

Aug 19, 2014, 7:47:13 PM8/19/14
to Nicolas Beucher,
Thanks for your response. The thing is that i like to use mamba3d.segment3d.label3d function on a 3d numpy array. But I dont understand how to do that. 
If I load the array slice by slice, how can I combine them together to be a 3D tensor so I can apply label3d on it?

Thank you very much

Serge Beucher

Aug 21, 2014, 3:46:38 AM8/21/14
to, Nicolas Beucher

I don't clearly understand your problem. If you want to use the Mamba 3D segmentation tools (watershed transformation), your 3D image must be stored in a Mamba image created with image3DMb. This 3D image is basically a pile of 2D Mamba images. Suppose that your 3D Mamba image is named im3D. Then, you need to extract each slice i of your numpy array (I am not familiar with numpy but I know that this slicing tool exists) and store it in the corresponding slice im3D[i] of the Mamba 3D image. To achieve this, have a look on the example already cited in Nicolas' answer.
Be aware also that the horizontal size of the Mamba image is always a multiple of 64. So, if your array has a different horizontal size, it will be padded with 0. This may induce problems (edge effects) if you don't take care of this.

Once, you have a 3D Mamba image, you can apply on it the 3D watershed transform (valuedWatershed3D). The basinSegment3D or watershedSegment3D operators can not be used directly on the initial image, as they require a labelled flooding source image (generated by label3D). Here again, have a look on the documentation given in the Mamba examples:

and also on other papers explaining how to use the watershed transformation which can be found on my web page:



You received this message because you are subscribed to the Google Groups "Mamba Image" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit

Reply all
Reply to author
0 new messages