errror using uigetdir

I have a code for reading images from a folder
FullPath=uigetdir('');
TestFiles=dir(FullPath)
for m=1:length(Testfiles)
S=imread([FullPath '\' TestFiles(k).name])
figure,imshow(S)
end
i get error as
Error using ==> imread at 368
Can't open file "F:\face recognization\faces\." for reading;
you may not have read permission.
please help

 채택된 답변

Titus Edelhofer
Titus Edelhofer 2012년 4월 30일

0 개 추천

Hi,
if you take a look at TestFiles(1).name you will see the ".", which is the current folder. Several possibilities: if you e.g. only have files with .jpg, you could write
TestFiles = dir(fullfile(FullPath, '*.jpg'));
or similar for other file formats. If you need all image files, be sure to not read "." and ".." by e.g.
if ~strcmp(TestFiles(i).name, '.') && ~strcmp(TestFiles(i).name, '..')
S = imread(...);
end
Titus

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Convert Image Type에 대해 자세히 알아보기

질문:

Pat
2012년 4월 30일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by