Geodesic dilation inside 3D Binary Mask

90 views
Skip to first unread message

eric.mo...@gmail.com

unread,
Jul 9, 2015, 8:48:58 AM7/9/15
to mamba...@googlegroups.com
Hello,

I have been searching online for 3D Mathematical Morphology tools, in particular geodesic dilation, and I have found your wonderful Python package, Mamba. I would like to know if Mamba could be used for my research. By the way, I am studying in Paris, so if my problem seems complicated, I would very much be willing to come to your lab in person.

In the photo I attached, I would like to apply a 3D geodesic dilation of the red dot (where the crosshairs are) inside the blue mask. The attached image is a brain imaging file (.nii). I can load both of these volumes in python (blue mask and red dot) and convert them to a numpy array (size 100x120x58). They are both binary masks (black = 0, blue = 1, red = 1). What I would like to do then is use the tools in Mamba to apply a geodesic dilation on the red binary volume constrained by the blue binary volume. Is this possible?

Best regards,
Eric Moulton

P.S. I am also having some trouble downloading Mamba and Mamba3D on my computer. When I try to import Mamba3D in Python, I get the following error message:


In [4]: import mamba3D
Missing PIL or PILLOW libraries - See MAMBA User Manual
Missing Mamba library - http://www.mamba-image.org
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-4-01c17093f2e0> in <module>()
----> 1 import mamba3D

/usr/local/lib/python2.7/dist-packages/mamba3D/__init__.py in <module>()
6 # Mamba imports
7 try:
----> 8 import mamba
9 _mb_version = mamba.VERSION.split('.')
10 if int(_mb_version[0])!=1 and int(_mb_version[1])!=1:

/usr/local/lib/python2.7/dist-packages/mambaIm/mamba.py in <module>()
10 import mambaCore
11 import mambaUtils as mbUtls
---> 12 from mambaDisplay import getDisplayer, setMaxDisplay, setMinDisplay
13 from mambaError import raiseExceptionOnError, raiseWarning, MambaError
14

/usr/local/lib/python2.7/dist-packages/mambaIm/mambaDisplay.py in <module>()
18 except ImportError:
19 try:
---> 20 from PIL import ImageTk
21 from PIL import Image
22 except ImportError:

ImportError: cannot import name ImageTk

---
I have tried redownloading the PIL library, but the only package inside of it that is missing is ImageTk! I have followed the instructions in the readme of the Mamba.1.1.3.zip file downloaded from the website, and the instructions of the Mamba3D users guide.

geodesic_erosion.png

eric.mo...@gmail.com

unread,
Jul 9, 2015, 9:29:49 AM7/9/15
to mamba...@googlegroups.com, eric.mo...@gmail.com
Hello all,

I am able to import mamba3D in python now. The main problem now is to use a geodesic dilation on my 3D array.

Thank you,
Eric

eric.mo...@gmail.com

unread,
Jul 9, 2015, 12:05:54 PM7/9/15
to mamba...@googlegroups.com, eric.mo...@gmail.com
Hello everyone,

I guess I had a stroke of inspriation after being stuck, and I figured out what to do, so I will share my code for those who would like to do something similar. Just for a note, my .nii.gz images are of size 100x120x58, but I had to extend the second dimension to 128 (which is why I append 8 zero matrices onto my image arrays, but then I remove it at the end).

I've also shared the result of the geodesically eroded point in the image below (radius = 1 (red), 2 (blue), 3 (green), 4 (yellow) )

If I were to use these results in a publication, how would you prefer that I cite you? Thanks a lot for such a great Python package !

geodesic_erosion_1-4.png
geodesic_dilation.py

Nicolas Beucher

unread,
Jul 10, 2015, 3:06:50 PM7/10/15
to mamba...@googlegroups.com, eric.mo...@gmail.com, eric.mo...@gmail.com
Hello,

Mamba needs the imageTk extension linking PIL or Pillow to the tkinter library. Sadly it is not obvious in the documentation. Seeing that you managed to make mamba functional you certainly figured that yourself.

Glad you were able to perform the computation you wanted and that Mamba helped you. If you want to cite us a link to the website would be nice.

Nicolas
Reply all
Reply to author
Forward
0 new messages