필터 지우기
필터 지우기

"Assignment has more non-singleton rhs dimensions than non-singleton subscripts" error

조회 수: 1 (최근 30일)
Any answer from you it will be priceless.
My images are 1701 from a highway (colored but i turn them in gray), where i am trying to do background substraction. % I have this code:
imgname = [imPath filesep filearray(1).name];
I = imread(imgname);
I=rgb2gray(I);
VIDEO_WIDTH = size(I,2);
VIDEO_HEIGHT = size(I,1);
ImSeq = zeros(VIDEO_HEIGHT, VIDEO_WIDTH, NumImages);
for i=1:NumImages
imgname = [imPath filesep filearray(i).name];
ImSeq(:,:,i) = imread(imgname);
end
disp(' ... OK!');
And in the ImSeq(:,:,i) line i am taking the "Assignment has more non-singleton rhs dimensions than non-singleton subscripts" error.
How can I fix it?

채택된 답변

dpb
dpb 2016년 10월 3일
"...colored but i turn them in gray"
But you didn't do that in the loop where you try to build the array, only in the first block of code where it doesn't really matter as you do nothing with the result.
ImSeq(:,:,i) = rgb2gray(imread(imgname));
  댓글 수: 2
XRYSANTHI
XRYSANTHI 2016년 10월 3일
Man,you are power.... I do not even thought that.. Problem solved!
dpb
dpb 2016년 10월 3일
Not as hard as may seem...when you've seen the error enough, you know where to look--and it's not like there's much code here! :)
BTW, it's a nit but a nice MATLAB idiom is
ImSeq = zeros([size(I) NumImages]);
which eliminates the temporary variables. Note the [] to put the elements into a vector. It also illustrates the facility with Matlab to use output from function as input to another--very powerful.

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

추가 답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by