Read multiple files

Hi all... I want to read some images with different names from my directory.
Example: I have 10 images(*.gif). Their names are : apple.gif, banana.gif, watermelon.gif, etc. How i can read all images in 1 executions? Thank you.
BR, Boris

 채택된 답변

Thomas
Thomas 2012년 5월 28일

3 개 추천

댓글 수: 4

Boris
Boris 2012년 5월 28일
Thank you Thomas.
I have 1 more problem.
http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
According to that link, how i can input (only my image name) in array ?
so the output will be like this :
array(1,1) = apple
array(2,1) = banana
array(3,1) = watermelon
....
array(n,1) = nfriuts
thank you.
BR,
Boris
Thomas
Thomas 2012년 5월 28일
You could try
name={'apple','banana','mango'}; % put this before the loop
for k=1:....
jpgFilename = strcat(name(k), '.jpg');
end
Boris
Boris 2012년 5월 28일
wow thank you Thomas. It's work. :D
Jisha
Jisha 2012년 5월 28일
It is customary to accept answers if it solved your problem, so as to let others know that a good solution is available here..

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

추가 답변 (1개)

Image Analyst
Image Analyst 2012년 5월 28일

0 개 추천

What is "one execution"? You'll need to call imread() 10 times - once for each image. You'll need to change the filename for each call, which it looks like you'll have to do manually since your filenames don't depend on any loop index or anything like that (unless you want to make a cell array or use a cell array like you get from dir()). I recommend just putting the 10 calls to imread directly into your code and I don't recommend using a loop unless the exact filenames are not known in advance, like you need to call dir() to retrieve them or something. If that is the case, the see the FAQ like Thomas pointed you to.
So is 10 calls to imread in one single m file "one execution" according to your definition? I hope so because that's pretty much the only way to do it.

댓글 수: 2

Boris
Boris 2012년 5월 28일
Thank you Image Analyst.
My problem like this : http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
How i can save 'baseFileName' in array ?
Image Analyst
Image Analyst 2012년 5월 29일
baseFileName{k} = jpegFiles(k).name; % Note: {k}, not (k) on the LHS

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

카테고리

도움말 센터File Exchange에서 Search Path에 대해 자세히 알아보기

질문:

2012년 5월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by