Saving Tiffs from cell array using imwrite in a loop

1 回表示 (過去 30 日間)
Jack Robertson
Jack Robertson 2019 年 8 月 27 日
コメント済み: Jack Robertson 2019 年 8 月 27 日
HI,
I am new to matlab and can't figure this out. I have got code set up to split up my large tiff files into sub sections which are contained within a cell array (ca). I can write these files out individually using:
imwrite((ca{1:1}), 's1.tiff', 'compression','none')
but what i want to do is write all the tiffs from the cell array with sequesntial names (s1, s2, s3, etc)

採用された回答

Jan
Jan 2019 年 8 月 27 日
編集済み: Jan 2019 年 8 月 27 日
for k = 1:numel(ca)
imwrite(ca{k}, sprintf('s%d.tiff', k), 'compression', 'none');
end
Prefer a naming scheme like s0001.tiff instead, then using dir replies the files in the original order:
sprintf('s%04d.tiff', k)
  1 件のコメント
Jack Robertson
Jack Robertson 2019 年 8 月 27 日
Thanks for this, it has worked great :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by