Read names of images from text file and read using imread
2 ビュー (過去 30 日間)
古いコメントを表示
Hi, I have some images to read in MATLAB and the names of the images are stored in a text file please let me know how can I read images one by one using imread, in addition to that the names of the image files contains '.' and '_' and my demand is to use the names as it is because these images are in sequence. Thanks
2 件のコメント
回答 (2 件)
Azzi Abdelmalek
2014 年 7 月 5 日
f=fopen('file.txt');
s=textscan(f,'%s ');
fclose(f);
out=s{1};
for k=1:numel(out)
filename=out{k}
%do
end
0 件のコメント
Image Analyst
2014 年 7 月 5 日
編集済み: Image Analyst
2014 年 7 月 5 日
Use fgetl():
fid = fopen('image_names.txt');
textLine = fgetl(fid);
while ischar(textLine)
fprintf('Now reading %s\n', textLine);
theImage = imread(textLine);
% Now process that image.
% Now read the next line.
tline = fgetl(fid);
end
fclose(fid);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Import, Export, and Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!