필터 지우기
필터 지우기

How to access image name in imageDatastore?

조회 수: 12 (최근 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);
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by