フィルターのクリア

I want to use a folder of images in matlab ..I tried but it comes to error..pls help me to point out error

1 回表示 (過去 30 日間)
This is the program that I have tested:
% Get a list of all files in the folder with the desired file name pattern.
filePattern = fullfile('C:\Program Files\MATLAB\R2009a\bin\fundus\*.jpg');
imagefile = dir(filePattern);
nfiles=length(imagefile)
for k = 1 : nfiles
imageName = imagefile(k).name;
fullFileName = fullfile('C:\Program Files\MATLAB\R2009a\bin\fundus\*.jpg', imageName);
fprintf(1, 'Now reading %s\n', fullFileName)
% Now do whatever you want with this file name,
% such as reading it in as an image array with imread()
imageArray = imread('C:\Program Files\MATLAB\R2009a\bin\fundus\*.jpg');
imshow(imageArray); % Display image.
drawnow; % Force display to update immediately.
end
and error comes as following:
nfiles =
70
Now reading C:\Program Files\MATLAB\R2009a\bin\fundus\*.jpg\im.jpg
??? Error using ==> imread at 357
Can't open file "C:\Program Files\MATLAB\R2009a\bin\fundus\*.jpg"
for reading;
you may not have read permission.
Error in ==> see at 11
imageArray = imread('C:\Program
Files\MATLAB\R2009a\bin\fundus\*.jpg');
  2 件のコメント
Brendan Hamm
Brendan Hamm 2017 年 9 月 20 日
Please format your code using the Code{} button.
Rik
Rik 2017 年 9 月 20 日
Why don't you use the debugger to go through your code to execute it line by line. The code you have in your post is very difficult to read with this lay-out, but I expect there is something wrong with how you generate the files names to be feed to imread, which is why it surprises me it doesn't error at n=1.

サインインしてコメントする。

採用された回答

Tim Berk
Tim Berk 2017 年 9 月 20 日
編集済み: Tim Berk 2017 年 9 月 20 日
% Get a list of all files in the folder with the desired file name pattern.
filePattern = fullfile('*.eps');
imagefile = dir(filePattern);
nfiles=length(imagefile);
for k = 1 : nfiles
imageName = imagefile(k).name;
fullFileName = fullfile('C:\Program Files\MATLAB\R2009a\bin\fundus\*.jpg', imageName);
fprintf(1, 'Now reading %s\n', fullFileName)
% Now do whatever you want with this file name,
% such as reading it in as an image array with imread()
imageArray = imread('C:\Program Files\MATLAB\R2009a\bin\fundus\*.jpg');
imshow(imageArray); % Display image.
drawnow; % Force display to update immediately.
end
If you would go through it line-by-line, you would see that
fullFileName = 'C:\Program Files\MATLAB\R2009a\bin\fundus\*.jpg\im.jpg'
This is because you already have the file name in imageName and are combining this with the ...\*.jpg
Just change this line to
fullFileName = fullfile('C:\Program Files\MATLAB\R2009a\bin\fundus\', imageName);
To get the proper file name.
Now you need to actually use this name, i.e.
imageArray = imread(fullFileName);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAgriculture についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by