%% Load images from folder
% Use imageSet to manage images stored in multiple folders
imset = imageSet('pet_images','recursive');
% Preallocate arrays with fixed size for prediction
imageSize = cnnModel.net.normalization.imageSize;
trainingImages = zeros([imageSize sum([imset(:).Count])],'single');
% Load and resize images for prediction
for ii = 1:numel(imset)
for jj = 1:imset(ii).Count
imshow(read(imset(ii),jj));
trainingImages(:,:,:,jj) = imresize(single(read(imset(ii),jj)),imageSize(1:2));
end
end
I want to read images from a directory. But it gives me error some images.
Assignment has fewer non-singleton rhs dimensions than non-singleton subscripts
I use breakpoint to find which image has a problem. When it gives error, I catch the index of the image and show this image.
I find this image from this directory. it's order is 1061 (orders according to name) but value of jj is 1012.
I have three Question.
getting the name of image, you can use code below;
imshow(read(imset(ii),jj));
a = select(imset(ii),jj);
str = cellstr(a(1,1).ImageLocation);
title(str);
Because imageset orders alphabetically but different way(name) For example.