Read large image stack (TIFF)
This function can load image stacks larger than 4GB which is the typical limitation on image files. Designed to work with single-channel uncompressed TIFF stacks. Also works for files smaller than 4GB.
[stack_out,Nframes]= imread_big(stack_name,[i j]);
stack_name = the path and file name to the image stack
[i j] = optional frame number range to load (i = j is allowed)
Nframes = number of frames as determined by total file size divided by estimated size of each frame data block
stack_out = the output image stack of size [M x N x Nframes], where M x N is the size of each image.
Tristan Ursell (2019). imread_big -- read in TIFF stacks larger than 4GB (https://www.mathworks.com/matlabcentral/fileexchange/61376-imread_big-read-in-tiff-stacks-larger-than-4gb), MATLAB Central File Exchange. Retrieved .
Hi Nicolas -- sorry it's not working ... I would first try the uint16 solution, it's essentially guaranteed to work, but you can also try the very latest change I made (today) ... again, it's hard to de-bug at a distance like this, but if you're game, try it out. I was a bad experimentalist, and I changed two things about the code in the penultimate update, and now changed one thing back, which I think should fix the issue that threw an error most recently.
Hi Tristan, thank you for your update, unfortunately it is still not functionning and gives the following error :
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first
matrix matches the number of rows in the second matrix. To perform elementwise multiplication, use
I tried using '.*' without more success.
I will try to work on it and let you know if I find a solution with your code.
Also, I will consider generating uint16 instead of uint32 as you suggested.
Thank you again,
Re Nicolas: I just updated it to handle uint32 ... let me know if that works. Also, very rarely is there a benefit to using uint32 over uint16 for images ... so you could also just use FIJI to downsample to uint16 with very little loss of information (and then the file size would be small enough to process normally, i.e. with 'imread').
Hello Tristan, first of all, thank you for this very useful tool !
I am actually facing an issue with a 6.26Go (1080 x1080x1440) uint32 Tiff file.
I get the following error message when running imread_big :
Matrix dimensions must agree.
Error in imread_big (line 44)
start_point = stripOffset(1) + (0:1:(Nframes-1)).*stripByteCounts;
When I check the "info1" structure both "stripOffsets" and "stripByteCounts" are 1x540 double for the 1440 entries
ByteOrder is 'little-endian'.
Do you have a clue of what I am doing wrong or what is wrong with my files ?
Thank you for your help,
includes support for uint32 images
fixed minor bug
Create scripts with code, output, and formatted text in a single executable document.