Vectorization to store images in a 3D array?
Show older comments
I have a multitiff image which I want to store as a 3D array.
Here is the function I am using. However, I wanted to know if there is a way to vectorize the for loop at the end of the code to reduce processing time.
function Images = readMultiTiff(TifImage)
%Get the information in the multitiff image
info = imfinfo(TifImage);
%Get the number of images in the multitiff image
num_images = numel(info);
%Determine height and width
width = info.Width;
height = info.Height;
%Create an empty array the size of each image in the multitiff
BlankImage =zeros(width,height);
%Use that to build a 3D array to store all the tiff images in the multitiff
Images = uint16(zeros(size(BlankImage,2),size(BlankImage,1),num_images));
%Read and assign each image to SEMImages.
mywaitbar_handle = waitbar(0, 'Saving images...');
for k = 1:num_images
A = imread(TifImage, k);
Images(:,:,k) = A;
waitbar(k/num_images);
end
close(mywaitbar_handle)
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!