필터 지우기
필터 지우기

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