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

조회 수: 1 (최근 30일)
BB
BB 2018년 1월 9일
댓글: BB 2018년 1월 10일
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

채택된 답변

BB
BB 2018년 1월 10일
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
BB
BB 2018년 1월 10일
The only Thing is that, the calculation time is quite Long, about 30 sec. That means this solution can be improved!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by