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

1 次查看(过去 30 天)
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));

回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by