How to import TIFF stack into a 4D matrix? (2021)

I realize this question has been asked before, but the solution is now out-dated.
I currently use the following for loop, which is inefficient. In Python, I could use skimage.imread(fname) to load the data. Is there an equivalent in Matlab?
tstack = Tiff(fname);
[I, J, C] = size(tstack.read());
K = length(imfinfo(path));
data = zeros(K,I,J,C);
data(1,:,:,:) = tstack.read();
for n=2:K
tstack.nextDirectory();
data(n,:,:,:) = tstack.read();
end

Answers (1)

sir,may be consider tiff function to get data,such as
t = Tiff('peppers_RGB_tiled.tif','r');
imageData = read(t);
imshow(imageData);
title('Peppers Image (RGB)')

Asked:

on 19 Nov 2021

Answered:

on 20 Nov 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!