how i can import imagedatstore contains subfolder of image?

1 visualizzazione (ultimi 30 giorni)
hello every one
i want to load an imagedatastore that contains subfolder of image. I have used this programme but it doesn't work, where the database is the folder and it contains 5 subfolders
%% Load the dataset
rootFolder = 'database.mp;
imds = imageDatastore('database', 'IncludeSubfolders',1 ,'LabelSource', 'foldernames');
% after that i want to read the first 10 image of each subfolder i haev use this programme
for i=1:10
img = readimage(rootFolder, i);
end
also this code dosn't work how can i do that

Risposta accettata

Image Analyst
Image Analyst il 12 Apr 2020
Try this:
%% Load the dataset
% rootFolder = 'database.mp';
rootFolder = 'D:\OneDrive\Not Shared\Matlab\work\Tests'; % Wherever. Change to your computer...
imds = imageDatastore(rootFolder, 'IncludeSubfolders',1 ,'LabelSource', 'foldernames');
% after that i want to read the first 10 image of each subfolder i haev use this programme
for k = 1 : 10
thisFullFileName = imds.Files{k};
fprintf('Reading in %s.\n', thisFullFileName);
thisImage = readimage(imds, k);
imshow(thisImage);
drawnow;
end

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by