Borrar filtros
Borrar filtros

Converting TIFF cell array sequence to video

8 visualizaciones (últimos 30 días)
Brandon Hoy
Brandon Hoy el 6 de Mzo. de 2018
Editada: Mann Baidi el 30 de Abr. de 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);
end
mplay(A);
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.

Respuestas (1)

Mann Baidi
Mann Baidi el 30 de Abr. de 2024
Editada: Mann Baidi el 30 de Abr. de 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
open(v);
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
end
close(v);
implay('newfile.avi')
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!

Categorías

Más información sobre Import, Export, and Conversion en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by