How to access image name in imageDatastore?

22 ビュー (過去 30 日間)
Awais Khan
Awais Khan 2019 年 12 月 7 日
コメント済み: Awais Khan 2019 年 12 月 7 日
Hi everyone, Senerio of my problem is that, for example one folder contain one subfolder and in this subfolder images in jpg,bmp etc formate exist. and i am using "imageDatastore", is it possible that i can access image name e.g. 'abc.jpg', by using "imageDatastore", without complete path string like(folder/subfolder/abc.jpg). i only need 'abc' which is name image.


Image Analyst
Image Analyst 2019 年 12 月 7 日
Use fileparts():
imds = imageDatastore('*.png')
fullFileNames = vertcat(imds.Files)
for k = 1 : length(fullFileNames)
[folder, baseFileNameNoExt, ext] = fileparts(fullFileNames{k});
baseFileNameWithExt = [ baseFileNameNoExt, ext];
fprintf('Base file name #%d = %s\n', k, baseFileNameWithExt);
  1 件のコメント
Awais Khan
Awais Khan 2019 年 12 月 7 日
thankyou so much!


その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by