[Numpy-discussion] reading tiff images

Daniel Lepage dplepage at gmail.com
Tue Apr 26 14:31:34 EDT 2011

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

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.


On Tue, Apr 26, 2011 at 2:00 PM, Mathew Yeates <mat.yeates at 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 at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion

More information about the NumPy-Discussion mailing list