Effacer les filtres
Effacer les filtres

How can I convert multiple individual .tif files to a single .tif stack

21 vues (au cours des 30 derniers jours)
Joe Sheppard
Joe Sheppard le 3 Avr 2018
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
  2 commentaires
Joe Sheppard
Joe Sheppard le 4 Avr 2018
I ended up writing the first frame to tiff outside the loop and then selecting 'overwrite' and 'append' within the loop and that got it to work.
I really don't know why the usual WriteMode' 'append' name pair argument didn't work, but hey a fix is a fix.
Thanks for your suggestion in any case

Connectez-vous pour commenter.

Réponses (1)

Mann Baidi
Mann Baidi le 4 Avr 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!

Catégories

En savoir plus sur Data Import and Analysis dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by