how can i solve the error of reading permission during loading of number of images from a folder
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
tejas
am 28 Apr. 2013
Kommentiert: Walter Roberson
am 13 Nov. 2021
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 Kommentare
Akzeptierte Antwort
Bjorn Gustavsson
am 28 Apr. 2013
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 Kommentare
dipon roy
am 12 Nov. 2021
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
am 12 Nov. 2021
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);
Weitere Antworten (2)
Image Analyst
am 28 Apr. 2013
Try
d=dir('d:\train2\*.bmp');
3 Kommentare
Abdullah
am 4 Apr. 2016
Bearbeitet: Walter Roberson
am 12 Nov. 2021
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
am 13 Nov. 2021
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
am 3 Aug. 2020
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 Kommentar
Walter Roberson
am 3 Aug. 2020
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 .
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!