how can i solve the error of reading permission during loading of number of images from a folder
8 次查看(过去 30 天)
显示 更早的评论
d=dir('d:\train2');
for i=1:4
fname=d(i).name;
z=imread(fname,'bmp');
end
this code is giving error
??? Error using ==> imread at 358 Can't open file "." for reading; you may not have read permission.
help me out to solve this error please
0 个评论
采纳的回答
Bjorn Gustavsson
2013-4-28
Looks to me as if you're trying to open the directory itself ('./') as if it was an image. The return from dir called on a directory will contain both the directory ('.') and its parent directory ('..'). Either you have to check that what you're trying to open is an image, or list only the images.
HTH
3 个评论
dipon roy
2021-11-12
Hi. I have the same problem but I didn't understand your solution. I am new to matlab.So can you please explain in a little bit more details?
Walter Roberson
2021-11-12
projectdir = 'd:\train2';
d = dir(projectdir);
d([d.isdir]) = []; %remove all folders including . and ..
num_files = numel(d);
all_images = cell(num_files,1);
file_okay = false(num_files,1);
for K = 1 : num_files
fname = fullfile(projectdir, d(K).name);
try
all_images{K} = fread(fname);
file_okay(K) = true;
catch ME
warning('file "%s" is not a readable image', fname);
end
end
all_images = all_images(file_okay);
更多回答(2 个)
Image Analyst
2013-4-28
Try
d=dir('d:\train2\*.bmp');
3 个评论
Abdullah
2016-4-4
编辑:Walter Roberson
2021-11-12
Hello I have the same issue can you share with me how you solved it ?
tu1=imread('C:\Users\Mostwanted\Desktop\Upgrade 03062016\Upgrade 03062016\Adaptive Exposure\AEx2\','*.jpg');
Walter Roberson
2021-11-13
projectdir = 'C:\Users\Mostwanted\Desktop\Upgrade 03062016\Upgrade 03062016\Adaptive Exposure\AEx2';
d = dir(fullfile(projectdir, '*.jpg'));
num_files = numel(d);
all_images = cell(num_files,1);
file_okay = false(num_files,1);
for K = 1 : num_files
fname = fullfile(projectdir, d(K).name);
try
all_images{K} = fread(fname);
file_okay(K) = true;
catch ME
warning('file "%s" is not a readable image', fname);
end
end
all_images = all_images(file_okay);
Zheng Heliang
2020-8-3
I have the same issue, and finally I find out my problem: I opened too much files without closing them. https://www.mathworks.com/matlabcentral/answers/124335-caught-std-exception-exception-message-is-message-catalog-matlab-builtins-was-not-loaded-from-th
1 个评论
Walter Roberson
2020-8-3
Running out of file slots should never result in the error message reported here. The problem here is that the user assumed that the first two names returned were . and .. but Windows with NTFS does not make any promises about the order of files, and in practice there are several valid filename characters that can sort before .
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!