How can I convert multiple individual .tif files to a single .tif stack
24 views (last 30 days)
Show older comments
I am currently writing some code to convert each frame of a .avi file to a .tif file, but I would also like to store the resulting frames as a single file, i.e. a tif stack.
The imwrite feature 'WriteMode', 'append' is not working (and also not giving an error).
Below is the segment of code:
obj = VideoReader(currAVI); vid = read(obj); frames = obj.NumberOfFrames; mkdir(nameString); writeFolder = strcat(currFolder,'\', nameString); cd(writeFolder);
for x = 1 : frames
imwrite(vid(:,:,:,x),strcat('frame-',num2str(x),'.tif'), 'Compression', 'none', 'WriteMode', 'append');
end
Answers (1)
Mann Baidi
on 4 Apr 2024
Hi Joe,
Asumming you would like to store the frames of your .avi file in a single single stack of .tif file, but your facing issues in executing the same.
This is because you are using different filename (strcat('frame-',num2str(x),'.tif')) for each of the file in your 'imwrite' command.
imwrite(vid(:,:,:,x),strcat('frame-',num2str(x),'.tif'), 'Compression', 'none', 'WriteMode', 'append');
I would suggest you to use only one name for all the frames instead of multiple names.
You can try replacing the above line of code with the following line:
imwrite(vid(:,:,:,x),'sample.tif', 'Compression', 'none','WriteMode', "append");
I hope this will help in reslolving your quries!
0 Comments
See Also
Categories
Find more on Convert Image Type 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!