Why do I have Subscripted assignment dimension mismatch with imread(filename)
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Import, Export, and Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!