how i can import imagedatstore contains subfolder of image?

4 次查看(过去 30 天)
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

采纳的回答

Image Analyst
Image Analyst 2020-4-12
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

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by