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!