Errror using imwrite, can't use "append" in 'WriteMode'

10 ビュー (過去 30 日間)
Sai Sirish Gokavarapu
Sai Sirish Gokavarapu 2019 年 9 月 5 日
Hey there! I'm trying to use to convert a video ( .avi file) to a .tif STACK but unfortunately the code just converts it to a set of .tif images despite using 'WriteMode' and "append". Is there any other way to achieve in MATLAB ( if I'm not wrong ImageJ has this functionality)
Here's the code, it's similar to that of Joe's written a year ago.
%% To convert avi files to tif images
obj = VideoReader('video.avi');
vid = read(obj);
frames = obj.NumberOfFrames;
% This just converts them to a set of images
% for x = 1 : frames
% imwrite(vid(:,:,:,x),strcat('frame-',num2str(x),'.tif'));
% end
%This is meant to amend that and to make a .tif stack
for x = 1 : frames
imwrite(vid(:,:,:,x),strcat('frame-',num2str(x),'.tif'), 'Compression', 'none','WriteMode', "append");
end

採用された回答

Alex Mcaulley
Alex Mcaulley 2019 年 9 月 5 日
編集済み: Alex Mcaulley 2019 年 9 月 5 日
You are changing the file name for each frame, resulting in different tif images. To build a tif stack you just need to use ONE unique file name:
%% To convert avi files to tif images
obj = VideoReader('video.avi');
vid = read(obj);
frames = obj.NumberOfFrames;
% This just converts them to a set of images
% for x = 1 : frames
% imwrite(vid(:,:,:,x),strcat('frame-',num2str(x),'.tif'));
% end
%This is meant to amend that and to make a .tif stack
for x = 1 : frames
imwrite(vid(:,:,:,x),'myimage.tif', 'Compression', 'none','WriteMode', 'append');
end
  1 件のコメント
Sai Sirish Gokavarapu
Sai Sirish Gokavarapu 2019 年 9 月 5 日
Thanks Alex, I guess I overlooked it while modifying my code from previous version. :) It works now

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by