Re: slow imread, multiframe tiffs



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
.



Relevant Pages

  • Re: slow imread, multiframe tiffs
    ... ImageJ is just much better code. ... I use matlab to read and analyze multiframe tiff images. ... Iterative imread of a 1000 30x30 16 grayscale TIFF frames ...
    (comp.soft-sys.matlab)
  • Re: slow imread, multiframe tiffs
    ... Steve Eddins wrote: ... I use matlab to read and analyze multiframe tiff images. ... Loading this same tiff file in a image analysis program called ImageJ ... what indication do you have that "loading the file" is actually reading the pixels from all 1000 images? ...
    (comp.soft-sys.matlab)
  • Re: tifftagsread bug introduced in 2008a?
    ... would either crash MATLAB entirely or display a cryptic error message ... to have no problems with MATLAB v2007a imfinfofunction. ... message referenced above from imtifinfo at line 92. ... created the multi-page TIFF), it looks more like some sort of internal ...
    (comp.soft-sys.matlab)
  • tifftagsread bug introduced in 2008a?
    ... Has anyone else encountered a bug with 'imfinfo' for TIFF files ... to have no problems with MATLAB v2007a imfinfofunction. ... message referenced above from imtifinfo at line 92. ...
    (comp.soft-sys.matlab)
  • convert images into bits
    ... I need help on how to convert images (tiff) into a single ... sequence of digital symbols.Is there any matlab ...
    (comp.soft-sys.matlab)