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?
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 helpsimread
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With