Read names of images from text file and read using imread

조회 수: 2 (최근 30일)
Muhammad Usman
Muhammad Usman 2014년 7월 5일
편집: Image Analyst 2014년 7월 5일
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
Azzi Abdelmalek
Azzi Abdelmalek 2014년 7월 5일
Post the first lines of your text file
Muhammad Usman
Muhammad Usman 2014년 7월 5일
t1152886489.631946_x0.200554_y0.000158_a0.000639.jpeg
This is the name of one of my image

댓글을 달려면 로그인하십시오.

답변 (2개)

Azzi Abdelmalek
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

Image Analyst
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);

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by