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
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.