필터 지우기
필터 지우기

index exceeds matrix dimention

조회 수: 1 (최근 30일)
lama jallo
lama jallo 2012년 12월 18일
the error is in the line i have the three asterisks i cant figure it out, please help
Q=[16 11 10 16 24 40 51 61
12 12 14 19 26 58 60 55
14 13 16 24 40 57 69 56
14 17 22 29 51 87 80 62
18 22 37 56 68 109 103 77
24 35 55 64 81 104 113 92
49 64 78 87 103 121 120 101
72 92 95 98 112 100 103 99];
luma=double(luma);
luma=luma-128;
%dct
for i=1:8:size(luma,1)
for j=1:8:size(luma,2)
*** dluma(i:i+7,j:j+7)=dct2(luma(i:i+7,j:j+7));
temp(i:i+7,j:j+7)=dluma(i:i+7,j:j+7)./Q;
temp1(i:i+7,j:j+7)=round(temp(i:i+7,j:j+7));
end
end
  댓글 수: 1
Mark Whirdy
Mark Whirdy 2012년 12월 18일
please paste self-contained code with all variables defined to accommodate any would-be assisters,
P.S. "if true" is pointless
??? Undefined function or variable 'luma'.
Error in ==> Untitled2 at 12
luma=double(luma);

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

답변 (3개)

Matt Fig
Matt Fig 2012년 12월 18일
What is the Q doing there? We need to see code that we can copy/paste and it will run. So please fill in the missing variables by editing your question.

Walter Roberson
Walter Roberson 2012년 12월 18일
What did you initialize dluma as ?

Image Analyst
Image Analyst 2012년 12월 18일
편집: Image Analyst 2012년 12월 18일
Change the lines to:
for i=1:8:size(luma,1)-7
for j=1:8:size(luma,2)-7
so that i and j never actually hit the very end of the array. The problem is that if i and j are at the very end, then i+7 and j+7 will be past the end. Setting them to 7 less means that the loop will end before so that i+7 and j+7 will not exceed the end.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by