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 个评论

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!

Translated by