display image in subfolder of current folder
이전 댓글 표시
hi,
I to display an image which is in one of the sub-folders of the current directory. I know the name of the file. how will i know which sub-folder it is in and how will i display in it???
thanking you in advance.
채택된 답변
추가 답변 (1개)
Azzi Abdelmalek
2015년 8월 23일
filename='photo.jpg'; % your image
a=dir
b={a.name};
idx=cellfun(@isdir,b)
c=b(idx)
c=c(3:end)
for k=1:numel(c)
f=dir
ii=ismember(filename,{f.name})
if ii
im=imread(fullfile(pwd,f,filename))
figure
imshow(im)
break
end
end
댓글 수: 1
Walter Roberson
2015년 8월 24일
Note: it is not guaranteed that "." and ".." will be the first two entries in the directory list. The order is arbitrary. You should be testing against the names, not against the positions.
카테고리
도움말 센터 및 File Exchange에서 Images에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!