Reading multiple images from subfolders using MATLAB? (fList = subDir(cDir,'*.jpg'); please help me to figure out the error thank you

조회 수: 1 (최근 30일)
%%Copyright (c) 2014 CoVar Applied Technologies
prtPath('beta')
baseDir = fullfile(prtRoot,'dataGen','dataStorage','msrcorid');
if ~exist(baseDir,'dir')
error('prt:MissingData','Could not locate the MSRCORID database in the folder %s; please download the database and extract it from here: http://research.microsoft.com/en-us/downloads/b94de342-60dc-45d0-830b-9f6eff91b301/default.aspx',baseDir);
end
if nargin < 1
classList = {fullfile('flowers','single'),'chimneys'};
end
if ~isa(classList,'cell')
classList = {classList};
end
allClasses = {'aeroplanes\general','aeroplanes\single','animals\cows\general','animals\cows\single','animals\sheep\general','animals\sheep\single',...
'benches_and_chairs','bicycles\general','bicycles\side view, single','birds\general','birds\single','buildings','cars\front view','cars\general','cars\rear view','cars\side view',...
'chimneys','clouds','doors','flowers\general','flowers\single','kitchen_utensils\forks','kitchen_utensils\knives','kitchen_utensils\spoons','leaves','miscellaneous',...
'scenes\countryside','scenes\office','scenes\urban','signs','trees\general','trees\single','windows'};
allClasses = strrep(allClasses,'\',filesep);
if strcmpi(classList{1},'all')
classList = allClasses;
end
if nargin < 2
maxNumExamplesPerClass = inf;
end
resizeFact = .5;
imgCell = cell(length(classList),1);
for i = 1:length(classList)
cDir = fullfile(baseDir,classList{i});
if ~exist(cDir,'dir')
error('prt:MissingData','Could not locate the MSRCORID sub-folder %s',cDir);
end
fList = subDir(cDir,'*.jpg');%%the error is here it can not locate the sub-folder
imgCell{i} = cell(min([maxNumExamplesPerClass,length(fList)]),1);
for imgInd = 1:min([maxNumExamplesPerClass,length(fList)]);
img = imread(fList{imgInd});
img = imresize(img,resizeFact);
imgCell{i}{imgInd,1} = img;
end
end
x = cat(1,imgCell{:});
y = prtUtilY(cellfun(@(c)length(c),imgCell));
ds = prtDataSetCellArray(x,y);
ds.classNames = classList;

답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by