473,387 Members | 1,624 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

reading 3-d (multi-page) tiff images with python/pil

hello all,

i am using python (2.5) with the PIL (latest [last?] release), and i
am trying
to read in these 3-d tiff images we have. basically, i am following
some
example code that iterates through the images in the 3-d tiff file
like this:

import Image
import numpy

img = Image.open("myFile.tif")
imgArray = numpy.zeros( ( img.size[0], img.size[1], numFrames ),
numpy.uint8 )
frame = 0
try:
while 1:
img.seek( frame )
imgArray[:,:,frame] = img
frame = frame + 1
except EOFError:
img.seek( 0 )
pass

and i have to get "numFrames" by initializing a counter to zero,
looping
through the same "seek" statement, and returning the counter once EOF
has been reached.

two questions:
1) is there a faster way to do this? when i compare the time required
to
run this code versus analogous matlab code, the python version is
about
2 times slower (on average, 1.88 times slower when i time it with a
bunch
of different images). this may not seem like a lot, but when the
images
are frequently more than 1GB, it can add up.

2) is there a better way to get the numFrames (or to combine getting
the
numFrames with the rest of the code) so that i do not have to iterate
over
the seek() function twice?

any help/suggestions much appreciated...

thanks,
bryan

May 22 '07 #1
0 1749

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Curtis Justus | last post by:
Hi, I am reading in a multipage TIFF image and need to manipulate each page separately. After reading the image into an Image object, I set the page by using the SelectActiveFrame method. ...
3
by: Al | last post by:
Is it possible, using only VB.NET code, to extract a single page from a multipage tiff file?
2
by: Becker | last post by:
I have a two page TIFF document. I simply want to create an array of image and put the two pages of this multipage tiff in this array for some further processing on seperate "images." The...
0
by: munish | last post by:
Hi, I am trying to send a tiff file which contains multiple pages/frames as a dime attachment. When I am saving the file on the server only the first page of image gets saved. Any Ideasv how to...
2
by: Bdog | last post by:
I've been searching for the file PrintFramework.zip that I've seen linked on tons of posts but all the links are bad. Does anynone know where I can get a copy of this code, I hoping it is what I...
5
by: sascha.folville | last post by:
Hi, I've some trouble reading the containing frames of a multiframe tiff. First frame is a 1700X2400 px CCITT4, second in JPG 820x1200, third is a CCITT again ... and so on. My function...
0
by: snehal s | last post by:
How to merge tiff images which may be multipage or single page using C# in VS 2005?
0
by: Luke | last post by:
I have a big (500+ MB) multipage TIFF image file and a database file which contains index to each image in the TIFF file. The scheme of the database is very simple. imagename (text) byte...
0
by: Luke | last post by:
I have a big (500+ MB) multipage TIFF image file and a database file which contains index to each image in the TIFF file. The scheme of the database is very simple. imagename (text) byte...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.