Re: slow imread, multiframe tiffs
- From: Steve Eddins <Steve.Eddins@xxxxxxxxxxxxx>
- Date: Fri, 29 Jun 2007 10:25:16 -0400
runcyclexcski@xxxxxxxxx wrote:
Hi all,
I posted this ~3 months ago and got no response. So I am trying again.
I use matlab to read and analyze multiframe tiff images. An average
image is a 16 bit grayscale, 30 by 30 pixels, tens and hunreds of
thousands of images. I have problems with performance, to the point
when I am considering re-writing the whole code in VC++. Can anyone
suggest a way to speed matlab up? Generate libs from matlab and plug
them into VC++ code? I could even get a more powerful PC just to save
myself time needed to re-write the code in a faster language.
Here are the details.
Iterative imread of a 1000 30x30 16 grayscale TIFF frames takes 6.1
seconds. This is
despite the fact that I pre-allocate everything:
frames(height,width*i) = uint16(0);
frame(height,width) = uint16(0);
tic,
for index=1:i
frame = imread(fifile,'tiff',index);
frames(1:height,(index-1)*width+1:
(index-1)*width+width) = frame;
end
toc
elapsed_time = 6.1100
In fact, not-preallocating the arrays does not make a big difference
(~25% slower?).
This is on Pentium M 1.86, 512 mB of RAM IBM laptop.
Loading this same tiff file in a image analysis program called ImageJ
(Java-based?) takes 0.8 seconds. I am not a Java programmer, but the
Java source of ImageJ, and the matlab algorythms look the same. The
only difference is a factor of 10 in performance.
Hi,
About 70% of the time used by MATLAB for your example is in a MEX-file which simply calls functions in libtiff, a widely-used C library for TIFF I/O. So I'm not sure that you would see much benefit from writing your own C or C++ code.
When you use ImageJ, what indication do you have that "loading the file" is actually reading the pixels from all 1000 images? In other words, I'm wondering if your comparison is really "apples to apples."
Another thought - you're getting an average read time of 6ms per image. How long does your analysis step take for each image? Is the I/O is truly going to be your performance bottleneck?
--
Steve Eddins
http://blogs.mathworks.com/steve
.
- Follow-Ups:
- Re: slow imread, multiframe tiffs
- From: Steve Eddins
- Re: slow imread, multiframe tiffs
- References:
- slow imread, multiframe tiffs
- From: runcyclexcski
- slow imread, multiframe tiffs
- Prev by Date: Re: How to remnove an annoying bottleneck
- Next by Date: Re: CTRL-Z in Matlab 2007a on Intel Mac
- Previous by thread: slow imread, multiframe tiffs
- Next by thread: Re: slow imread, multiframe tiffs
- Index(es):
Relevant Pages
|