Extracting Tif from mat files.

1 view (last 30 days)
Tossawon Ngamnet
Tossawon Ngamnet on 22 Jul 2018
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

Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!