필터 지우기
필터 지우기

Converting TIFF cell array sequence to video

조회 수: 8 (최근 30일)
Brandon Hoy
Brandon Hoy 2018년 3월 6일
편집: Mann Baidi 2024년 4월 30일
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.

답변 (1개)

Mann Baidi
Mann Baidi 2024년 4월 30일
편집: Mann Baidi 2024년 4월 30일
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!

카테고리

Help CenterFile Exchange에서 Import, Export, and Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by