display image in subfolder of current folder
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Preethi
el 23 de Ag. de 2015
Comentada: Preethi
el 24 de Ag. de 2015
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.
0 comentarios
Respuesta aceptada
Image Analyst
el 24 de Ag. de 2015
Preethi, try this:
% Specify the top level folder.
topLevelFolder = 'C:\Users\Mark\Pictures';
% Add this folder and all of its subfolders to the search path.
addpath(genpath(topLevelFolder));
% Define the base file name of the file you are looking for.
baseFileName = 'anagrams.png';
% Display it. It will find it on the search path if it's there.
imshow(baseFileName);
Más respuestas (1)
Azzi Abdelmalek
el 23 de Ag. de 2015
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 comentario
Walter Roberson
el 24 de Ag. de 2015
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.
Ver también
Categorías
Más información sobre File Operations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!