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

1 visualizzazione (ultimi 30 giorni)
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));

Risposte (1)

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

Categorie

Scopri di più su Images in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by