Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the fastest way to load multiple image tiff file in matlab?

Tags:

image

matlab

I have a multiple image tiff file (3000 frames for example) and want to load the each image into matlab (I am using 2010a now). But I found it takes longer time to read images as the index of the frame increasing. The following is the code I am using now

   for i=1:no_frame;
   IM=imread('movie.tif',i);
   IM=double(IM);
   Movie{i}=IM;    
   end 

Is there any other way to do it faster?

like image 844
tytamu Avatar asked May 27 '11 20:05

tytamu


1 Answers

The TIFF-specific syntax list for IMREAD says the following for the 'Info' parameter:

When reading images from a multi-image TIFF file, passing the output of imfinfo as the value of the 'Info' argument helps imread locate the images in the file more quickly.

Combined with the preallocation of the cell array suggested by Jonas, this should speed things up for you:

fileName = 'movie.tif';
tiffInfo = imfinfo(fileName);  %# Get the TIFF file information
no_frame = numel(tiffInfo);    %# Get the number of images in the file
Movie = cell(no_frame,1);      %# Preallocate the cell array
for iFrame = 1:no_frame
  Movie{iFrame} = double(imread(fileName,'Index',iFrame,'Info',tiffInfo));
end
like image 56
gnovice Avatar answered Oct 14 '22 21:10

gnovice