Sean's suggestion was helpful, although it took a long time to run. I eventually figured out that I could import into the ImageDataStore everything in all the subfolders, using the subfolder names as labels, and then delete out everything that matched the labels I did not want to retain.
Questions about using ImageDataStore and only some subfolders in a folder
11 次查看(过去 30 天)
显示 更早的评论
These are related, so I will ask them both here:
1. Is it possible to specify which subfolders in a folder are to be used in an ImageDataStore? For example, if you have 5 subfolders but would like to use just 3 of the subfolders in your ImageDataStore, is that possible? I cannot tell from the ImageDataStore documentation.
2. Alternatively, is it possible to create an ImageDataStore and then add to it? If #1 is not possible then I can imagine a workaround in which I add to an ImageDataStore subfolder by subfolder.
0 个评论
采纳的回答
更多回答(2 个)
Sean de Wolski
2018-2-5
编辑:Sean de Wolski
2018-2-5
Build files with dir. For example, all pngs at this level and below. Then strip out any you don't want or keep just the ones you do:
d = struct2table(dir(fullfile(pwd, '**','*.png')));
d = d(ismember(d.folder, folders_you_want), :);
files = fullfile(d.folder, d.name)
(Untested in MATLAB)
0 个评论
michael scheinfeild
2018-7-18
use filter on subfolder
dbpathSave={'mainfold\case*\Na',...
'mainfold\case*\Nb',...
'mainfold\case*\Nc',};
exts ={'.jpg'};
imds = imageDatastore( dbpathSave,'FileExtensions',exts,'IncludeSubfolders',0,'LabelSource' ,'foldernames');
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!