Why do I have Subscripted assignment dimension mismatch with imread(filename)

1 vue (au cours des 30 derniers jours)
BB
BB le 9 Jan 2018
Commenté : BB le 10 Jan 2018
Hello,
I am facing an issue with "imread" in a Loop for but I do not know where it Comes from. What I want to do is to Access multiple Images that are in a Folder and read These Images at each k of the Loop. But then the code always stops and can't read the Images. This error always Comes up: "Subscripted assignment dimension mismatch. Error in test2 (line 40) pic(k,:,:)=imread(filename); %Read the Image"
For your Information, I have calculated: size(imread(filename)), I am having the following answer: 1024 1024 3 Hereunder my code. Thanks a lot for your help :)
fullpath=fullfile('c:\','Users','Images');
startN=0;
endN=881;
steplength=1;
width=1024;
height=1024;
index=1;
x=500;
y=500;
% Load the image from the hard disk
for k=1:(endN-startN+1)
clear imageN; %clear the memory
imageN=int2str(k+startN-1);
if k+startN-1<10
filename=strcat(fullpath,'Test BTR000',imageN,'.jpeg');
elseif k+startN-1<100
filename=strcat(fullpath,'Test BTR00',imageN,'.jpeg');
elseif k+startN-1<1000
filename=strcat(fullpath,'Test BTR0',imageN,'.jpeg');
% elseif k+startN-1<10000
% filename=strcat(fullpath,'Test BTR',imageN,'.jpeg');
else
filename=strcat(fullpath,'Test BTR',imageN,'.jpeg');
end
pic(k,:,:)=imread(filename); %Read the image
end
% to find the scaling corresponding to the interferograms
for k=1:(endN-startN+1)
value(k)=double(pic(k,y,x));
end

Réponse acceptée

BB
BB le 10 Jan 2018
I have just found out the solution, here is the code. It might help someone else:
fullpath=fullfile('c:\','Users','bbebey','Desktop','Projekts','WLI-PL','Matlab Auswertung','Auswertung mit CWT_numerical data','Images',filesep);
startN=0;
endN=881;
steplength=1;
width=1024;
height=1024;
index=1;
x=500;
y=500;
% Load the image from the hard disk
for k=1:(endN-startN+1)
clear imageN; %clear the memory
imageN=int2str(k+startN-1);
if k+startN-1<10
filename=strcat(fullpath,'Test BTR000',imageN,'.jpeg');
elseif k+startN-1<100
filename=strcat(fullpath,'Test BTR00',imageN,'.jpeg');
elseif k+startN-1<1000
filename=strcat(fullpath,'Test BTR0',imageN,'.jpeg');
% elseif k+startN-1<10000
% filename=strcat(fullpath,'Test BTR',imageN,'.jpeg');
else
filename=strcat(fullpath,'Test BTR',imageN,'.jpeg');
%Read the image
pictemp=imread(filename);
pic[k,1]=pictemp[x,y];
end
% find the scaling corresponding to the interferograms
for k=1:(endN-startN+1)
value(k)=double(pic[k,1]);
end
  1 commentaire
BB
BB le 10 Jan 2018
The only Thing is that, the calculation time is quite Long, about 30 sec. That means this solution can be improved!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by