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

Illustration
Esperanza - 2020-10-03T12:07:13+00:00
Question: how can i solve the error of reading permission during loading of number of images from a folder?

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 answered . 2025-11-20

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.


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!