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 CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by