How to know the size of imageDatastore?

조회 수: 21 (최근 30일)
Hadi Ghahremannezhad
Hadi Ghahremannezhad 2020년 9월 23일
답변: Srivardhan Gadila 2020년 9월 28일
Is there a function that returns the total number of images in an imageDatastore?
For example, if I load images from a directory and wanted to know the total number of images and index each image, how can I do that?
imds = imageDatastore(ipath, 'FileExtensions', {'.jpg', '.tif', '.png'});
i = 1;
while hasdata(imds)
[img, imgInfo] = readImage(imds, i);
fprintf('process %s \n', imgInfo.('Filename'));
i = i+1;
end
The above code shows out of index error ( i exceeds number of files ).
and is this the fastest way to read images from a location?

채택된 답변

Srivardhan Gadila
Srivardhan Gadila 2020년 9월 28일
You can access the Files property of the imageDatastore & call the numel function on it.
imds = imageDatastore({'street1.jpg','street2.jpg','peppers.png','corn.tif'})
numImages = numel(imds.Files)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by