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 Comment

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.

Sign in to comment.

Answers (0)

Categories

Products

Asked:

on 1 Apr 2019

Commented:

on 1 Apr 2019

Community Treasure Hunt

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

Start Hunting!