
Hi What is current method of using ndiimage on a Tiff file? I've seen different methods using ndimage itself, scipy.misc and Pil. Mathew

You need PIL no matter what; scipy.misc.imread, scipy.ndimage.imread, and scikits.image.io.imread all call PIL. Theoretically there's no difference between any of them, although in actuality some use "import Image" and others use "from PIL import Image"; one of these may fail depending on how you installed PIL. (I'm not sure which is supposed to be standard - the PIL docs use both interchangeably, and I think the latest version of PIL on pypi sets it up so that both will work). I'd use whichever tool you're already importing - if you're using ndimage anyway, just use ndimage.imread rather than adding more imports. Note that using PIL directly is easy, but does require adding an extra step; OTOH, if you're familiar with PIL, you can use some of its transformations from the start, e.g. def imread(fname, mode='RGBA'): return np.asarray(Image.open(fname).convert(mode)) to ensure that you always get 4-channel images, even for images that were initially RGB or grayscale. HTH, Dan On Tue, Apr 26, 2011 at 2:00 PM, Mathew Yeates <mat.yeates@gmail.com> wrote:
Hi What is current method of using ndiimage on a Tiff file? I've seen different methods using ndimage itself, scipy.misc and Pil.
Mathew _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

On Tue, Apr 26, 2011 at 8:31 PM, Daniel Lepage <dplepage@gmail.com> wrote:
You need PIL no matter what; scipy.misc.imread, scipy.ndimage.imread, and scikits.image.io.imread all call PIL.
Scikits.image has a plugin system for IO and can use FreeImage to load images. PIL's Tiff image handling is pretty buggy (especially multi-page and 16-bit tiffs), so that may be a good option too. Ralf

On Apr 26, 2011, at 2:31 PM, Daniel Lepage wrote:
You need PIL no matter what; scipy.misc.imread, scipy.ndimage.imread, and scikits.image.io.imread all call PIL.
scikits.image.io also has a ctypes wrapper for the freeimage library. I prefer these (well, I wrote them), though apparently there are some 64-bit issues (crashes?). I haven't been working on a 64-bit system so I haven't been able to address them, but I will be soon. It's a very thin wrapper around a simple image IO library, so there's lots of room to add and extend as need be... All of the PIL wrappers are kluges around serious flaws in how PIL reads images, particularly non-8-bit images and in particular non- native-endian 16-bit images. Zach
Theoretically there's no difference between any of them, although in actuality some use "import Image" and others use "from PIL import Image"; one of these may fail depending on how you installed PIL. (I'm not sure which is supposed to be standard - the PIL docs use both interchangeably, and I think the latest version of PIL on pypi sets it up so that both will work).
I'd use whichever tool you're already importing - if you're using ndimage anyway, just use ndimage.imread rather than adding more imports.
Note that using PIL directly is easy, but does require adding an extra step; OTOH, if you're familiar with PIL, you can use some of its transformations from the start, e.g.
def imread(fname, mode='RGBA'): return np.asarray(Image.open(fname).convert(mode))
to ensure that you always get 4-channel images, even for images that were initially RGB or grayscale.
HTH, Dan
On Tue, Apr 26, 2011 at 2:00 PM, Mathew Yeates <mat.yeates@gmail.com> wrote:
Hi What is current method of using ndiimage on a Tiff file? I've seen different methods using ndimage itself, scipy.misc and Pil.
Mathew _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

is scikits.image.io documented anywhere? On Tue, Apr 26, 2011 at 11:45 AM, Zachary Pincus <zachary.pincus@yale.edu> wrote:
On Apr 26, 2011, at 2:31 PM, Daniel Lepage wrote:
You need PIL no matter what; scipy.misc.imread, scipy.ndimage.imread, and scikits.image.io.imread all call PIL.
scikits.image.io also has a ctypes wrapper for the freeimage library. I prefer these (well, I wrote them), though apparently there are some 64-bit issues (crashes?). I haven't been working on a 64-bit system so I haven't been able to address them, but I will be soon. It's a very thin wrapper around a simple image IO library, so there's lots of room to add and extend as need be...
All of the PIL wrappers are kluges around serious flaws in how PIL reads images, particularly non-8-bit images and in particular non- native-endian 16-bit images.
Zach
Theoretically there's no difference between any of them, although in actuality some use "import Image" and others use "from PIL import Image"; one of these may fail depending on how you installed PIL. (I'm not sure which is supposed to be standard - the PIL docs use both interchangeably, and I think the latest version of PIL on pypi sets it up so that both will work).
I'd use whichever tool you're already importing - if you're using ndimage anyway, just use ndimage.imread rather than adding more imports.
Note that using PIL directly is easy, but does require adding an extra step; OTOH, if you're familiar with PIL, you can use some of its transformations from the start, e.g.
def imread(fname, mode='RGBA'): return np.asarray(Image.open(fname).convert(mode))
to ensure that you always get 4-channel images, even for images that were initially RGB or grayscale.
HTH, Dan
On Tue, Apr 26, 2011 at 2:00 PM, Mathew Yeates <mat.yeates@gmail.com> wrote:
Hi What is current method of using ndiimage on a Tiff file? I've seen different methods using ndimage itself, scipy.misc and Pil.
Mathew _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

On Tue, Apr 26, 2011 at 9:09 PM, Mathew Yeates <mat.yeates@gmail.com> wrote:
is scikits.image.io documented anywhere?
http://stefanv.github.com/scikits.image/api/scikits.image.io.html

On Tue, Apr 26, 2011 at 20:31, Daniel Lepage <dplepage@gmail.com> wrote:
You need PIL no matter what; scipy.misc.imread, scipy.ndimage.imread, and scikits.image.io.imread all call PIL.
I believe there are two pure python readers: http://code.google.com/p/pylibtiff/ http://www.lfd.uci.edu/~gohlke/code/tifffile.py.html The first can also write TIFF, but does not handle tiled TIFFs.
participants (5)
-
Daniel Lepage
-
Mathew Yeates
-
Ralf Gommers
-
Thouis (Ray) Jones
-
Zachary Pincus