Saving a stack of images

7 views (last 30 days)
Jason
Jason on 3 Mar 2017
Commented: Jason on 4 Mar 2017
Hi. I have a set of tiff images in an array (expressed as an array of double).
I want to save as a stack of images. I have tried:
for k=1:mx
imgArray2(:,:,k)=imgArray{k};
end
try
imwrite(imgArray2,sprintf('%s\\%s.stk',folder,prefix));
catch
h = errordlg('Error Saving Image STK')
end
But get the error message:
Subscripted assignment dimension mismatch.
Error in myProgram>pushbutton53_Callback (line 4016)
imgArray2(:,:,k)=imgArray{k};
  5 Comments
Walter Roberson
Walter Roberson on 3 Mar 2017
.stk appears to be Metamorph .stk files, which appear to be an extension of TIFF files. The contribution https://www.mathworks.com/matlabcentral/fileexchange/10298-tiffread2-m should be able to read .stk files. At the moment I do not know about writing .stk files.
Jason
Jason on 3 Mar 2017
Yes stk is from Metamorph. I dont need this format, just some way to collect a set of tiff images (which are doubles) and be able to save as a single file in any format. I would then later need to undo this and be able to eventually read the individual images.

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 3 Mar 2017
Try save():
save('tiff_stack.mat', 'imgArray2');

More Answers (0)

Community Treasure Hunt

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

Start Hunting!