Converting TIFF cell array sequence to video
7 ビュー (過去 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.
0 件のコメント
回答 (1 件)
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!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!