473,807 Members | 2,877 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("myF ile.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 1803

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

Similar topics

0
1675
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. Then, I am converting it to an individual Bitmap/Image. Here is a sample: ---------------------- FrameDimension fd = _image.SetActiveFrame(fd, 0); Bitmap bmp = new Bitmap(_image);
3
11016
by: Al | last post by:
Is it possible, using only VB.NET code, to extract a single page from a multipage tiff file?
2
8642
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 problem is that i can use the image.selectactiveframe to get to the individual page, but everytime i tray to say: img(icount) = myimg.SelectActiveFrame(oFDimension, iCount) The problem is that the entire tiff is put into img(icount). Any ideas?
0
1343
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 pass Multipage tiff
2
2070
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 need to get me going on printing multipage tiff. Thanks
5
4640
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 extracts the CCITT-frames correct, but the second, fourth, etc. frames causes a general GDI+ error. Hope someone can help!
0
1286
by: snehal s | last post by:
How to merge tiff images which may be multipage or single page using C# in VS 2005?
0
1239
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 offset (integer)
0
1478
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 offset (integer) So, it would list as
0
10626
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10374
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10112
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6879
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3854
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.