フィルターのクリア

Extracting Tif from mat files.

1 回表示 (過去 30 日間)
Tossawon Ngamnet
Tossawon Ngamnet 2018 年 7 月 22 日
Dear all, i follow this code (T1.jpg) for extracting Tif images from .mat files. When the mat files was load to workspace, it will show IR0001__(2underscores). The problem is that after mat file number 10000 will show IR10000_ (it represent one underscore '_'). Then i try to rewrite my code as picture (T2.jpg). The result is shown 1000 Tif images only ( 1.jpg and result 1.1.jpg ). --------------------------------------------------------------------------------------------------------------------------- code: output_folder = 'C:\Users\Tossaworn\Desktop\Xef2Mat-master'; files = dir('*.mat'); for fidx = 1:numel(files) if fidx < 10000 matcontent = load(files(fidx).name); %load into structure filenumber = regexp(files(fidx).name, '\d+', 'match', 'once'); %get numeric part of filename imagename = sprintf('IR%s__', filenumber); %build variable name assert(isfield(matcontent, imagename), 'mat file %s does not contain image %s', files(fidx).name, imagename); outputfilename = fullfile(output_folder, sprintf('test%s.tif', filenumber)); imwrite(matcontent.(imagename), outputfilename); else matcontent = load(files(fidx).name); %load into structure filenumber = regexp(files(fidx).name, '\d+', 'match', 'once'); %get numeric part of filename imagename = sprintf('IR%s_', filenumber); %build variable name assert(isfield(matcontent, imagename), 'mat file %s does not contain image %s', files(fidx).name, imagename); outputfilename = fullfile(output_folder, sprintf('test%s.tif', filenumber)); imwrite(matcontent.(imagename), outputfilename); end end -----------------------------------------------------------------------------
Please suggest
Thank you

回答 (0 件)

カテゴリ

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

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by