[Numpy-discussion] create a numpy array of images

totonixsame at gmail.com totonixsame at gmail.com
Wed Feb 2 05:41:28 EST 2011

On Wed, Feb 2, 2011 at 8:22 AM, Asmi Shah <asmi.capri at gmail.com> wrote:
> Hi all,
> It seems that using 64 bit python is the solution. But the thing is i would
> compile my code and wanna distribute it to the clients.. and that is the
> only reason why i want to work on 32 bit system. Sturla, how I can make it
> sure that some part of the data is kept on the disk and only the necessary
> one in the memory; as this seems to be a solution to my problem. As i said i
> want a 3d visualization out of the numpy array. it works fine for the
> downsampled dataset. And to visualize, i have to convert the 16bit data into
> 8bit as PIL doesnt support 16 bit data.. the only thing i do to create my
> array is this:
> stack = numpy.empty((120, 1024, 1024))
> i = 0
> os.chdir(dirr)
> for f in os.listdir(dirr):
>     im = Image.open(f)
>     im = im.convert("L")
>     a = numpy.asarray(im)
>     print a.dtype
>     stack[i] = a
>     i += 1
> one more thing, it really doesnt work for tiff files at all, i have to
> convert them into jpgs as a prior step to this. and it at max lets me create
> an array for around 60 slices only, where as my requirement would be around
> 100 to 200 images..
> any ideas? can diagnose the problem??
> thanks a lot.. asmi

Give a try to pylibtiff [1], the cool thing is it give support to get
metainformations from tiff files. There is support to read tiff files
in VTK [2].

[1] - http://code.google.com/p/pylibtiff/
[2] - http://www.vtk.org/doc/nightly/html/classvtkTIFFReader.html

More information about the NumPy-Discussion mailing list