How do I read in images of different dimensions into an array in matlab

1 view (last 30 days)
Goodmorning somebody there, I want to read in images of different dimensions into an array but am having this error
??? Subscripted assignment dimension mismatch.
Error in ==> loadExample at 10
myArray(:,:,:,p) = imread(fullfile(H, myFile{p}));
my code is as below:
H = fullfile('C:\Users','Adigun','My Documents','One_Thousand');
myFolder = dir(fullfile(H,'0*.jpg'));
myFile = {myFolder.name};
numImage = numel(myFile);
I = imread(fullfile(H, myFile{1}));
%figure(7), imshow(I);
myArray = zeros([size(I) numImage], class(I));
%myarray(:,:,1) = I;
for p = 1:numImage
myArray(:,:,:,p) = imread(fullfile(H, myFile{p}));
end
figure(8), imshow(myArray(:,:,:,2));

Answers (1)

Andrei Bobrov
Andrei Bobrov on 6 Aug 2012
try this is code:
myArray = cell(1,numImage);
for p = 1:numImage
myArray{p} = imread(fullfile(H, myFile{p}));
end

Community Treasure Hunt

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

Start Hunting!