Filter löschen
Filter löschen

Converting TIFF cell array sequence to video

7 Ansichten (letzte 30 Tage)
Brandon Hoy
Brandon Hoy am 6 Mär. 2018
Bearbeitet: Mann Baidi am 30 Apr. 2024
I am trying to take a multipage tiff file and convert it to video, I'm not proficient in Matlab at all. I'm using code that I found on a tutorial for converting multipage tiff images into seperate viewable images. The code is as follows:
fname = 'vid.tiff';
info = imfinfo(fname);
num_images = numel(info);
for k = 1:num_images
A(:,:,k) = imread(fname, k, 'Info', info);
I originally had the imread saving to a cell array, but that didn't work with mplay, so I changed it to a matrix. It seems to work as it runs a video of the right number of frames after I run the script, but the video that plays is only black images. I know the images have information in them because I can view each of them seperately. I'm honestly not even sure what this code does, I just know that it seems to work up until the video output.

Antworten (1)

Mann Baidi
Mann Baidi am 30 Apr. 2024
Bearbeitet: Mann Baidi am 30 Apr. 2024
I am assuming you would like to convert a multilayer tiff file to a video and play using the mplay function.
I would sugget you to use the 'VideoWriter' object to create a video object and then can add the frames using the 'writeVideo' function.
You can take help of the following code as a reference.
v = VideoWriter('newfile.avi','Uncompressed AVI'); % Creating a video format of .avi format
tiff_file= 'this.tif';
tiffInfo = imfinfo(tiff_file);
numFrames=numel(tiffInfo); % Number of frames in the tiff file
for k=1:numFrames
x=imread(tiff_file,k); % Reading the tiff file frame-by-frame
v.writeVideo(x); % Add the frame in the video
You can know more about the 'VideoWriter' object using the documentation link mentioned below:
I am hoping that I helped you in resloing your issue!


Community Treasure Hunt

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

Start Hunting!

Translated by