how can i solve the error of reading permission during loading of number of images from a folder?

E
Esperanza · Oct 3, 2020 · 2.2K views
Question
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
Expert Answer
Profile picture of Prashant Kumar
Prashant Kumar PhD Expert
Answered Aug 16, 2026

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.

100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!