Index exceeds array bounds.
이전 댓글 표시
this is the part of my code. i am trying to use matlab to train data. there is a folder named (label) and there are 400 pictures in this folder. and errors happen...
my english isnt that well. sorry..
hope someone can help me. thx a lot
------------------------------------------------------------------
%% generate data
filepaths = dir(fullfile(folder,'*.bmp'));
labelpaths = dir(fullfile(folder,'*.bmp'));
for i = 1 : 380 %length(filepaths)
im_input = im2double(imread(fullfile(folder,filepaths(i).name)));
im_label = im2double(imread(fullfile(labelfold,labelpaths(i).name)));
[hei,wid] = size(im_label);
for x = 1 : stride : hei-size_input+1
for y = 1 :stride : wid-size_input+1
subim_input = im_input(x : x+size_input-1, y : y+size_input-1);
subim_label = im_label(x+padding : x+padding+size_label-1, y+padding : y+padding+size_label-1);
count=count+1;
data(:, :, 1, count) = subim_input;
label(:, :, 1, count) = subim_label;
end
end
end
order = randperm(count);
data = data(:, :, 1, order);
label = label(:, :, 1, order);

my version is R2018b
댓글 수: 1
Walter Roberson
2019년 4월 1일
You did not have at least 380 different .bmp files in the folder.
Note: you use the same folder for filepaths and labelpaths when doing the dir(), but you use different folder names when duing the fullfile for imread purposes.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!