Filter löschen
Filter löschen

Reading multiple images from a folder in MATLAB Directory

1 Ansicht (letzte 30 Tage)
Said Rahal
Said Rahal am 10 Jul. 2012
I need to read several images from a folder in MATLAB Directory, in order to do several operations on it, I have written the following code:
Directory = fullfile ('C:','Users','ssr729','Documents','MATLAB','image');
Images = dir(fullfile(Directory,'*.jpg'));
Names = {Images.name}';
for k=1: numel(Names)
I = imread(Names{k});
%operations
end
I am receiving this error and I do not know why:
Error using imread (line 372)
File "polymerc.jpg" does not exist.
Even though the image 'polymera.jpg' does exist in the specified path. Any help is really appreciated. Thanks

Akzeptierte Antwort

F.
F. am 10 Jul. 2012
you lost the path ...
try:
imread( fullfile( Directory, Names{k} ) )
  4 Kommentare
Image Analyst
Image Analyst am 10 Jul. 2012
Well, apparently the images live in the C:\Users\ssr729\Documents\image folder and not the C:\Users\ssr729\Documents\MATLAB\image folder. It will work if it looks in the right folder, and it won't work if it looks in the wrong folder - makes sense?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Thomas
Thomas am 10 Jul. 2012
Your error states that
Error using imread (line 372) File "polymerc.jpg" does not exist.
Even though the image 'polymera.jpg' does exist in the specified path
Notice the difference between ploymerc and polymera The two files are different..
Also please go through the following which might help
  1 Kommentar
Said Rahal
Said Rahal am 10 Jul. 2012
Thanks Binish for pointing this out, but in the folder I have the two images '*polymera*' and '*polymerc*' and still I have the mentioned error above.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by