error 'index exceeds matrix dimensions'
信息
此问题已关闭。 请重新打开它进行编辑或回答。
显示 更早的评论
figure
for i=1:11
y(:,:,k3)=idwt2(llf(:,:,i),lhf(:,:,i),hlf(:,:,i),hhf(:,:,i),'haar');
s=mat2gray(y(:,:,k3));
subplot(4,4,i)
imshow(s);
k3=k3+1;
end
figure
i1=1;
j1=1;
a1(i1:i1+63, j1:j1+63)=mat2gray(cell2mat(P(1)));
a1(i1:i1+63, 65:65+63)=mat2gray(cell2mat(P(2)));
a1(i1:i1+63, 129:129+63)=mat2gray(cell2mat(P(3)));
a1(i1:i1+63, 193:193+63)=mat2gray(cell2mat(P(4)));
a1(65:65+63, j1:j1+63)=mat2gray(cell2mat(P(5)));
a1(65:65+63, 65:65+63)=mat2gray(s(:,:,1));
a1(65:65+63, 129:129+63)=mat2gray(s(:,:,2));
a1(65:65+63, 193:193+63)=mat2gray(s(:,:,3));
a1(129:129+63, j1:j1+63)=mat2gray(s(:,:,4));
a1(129:129+63, 65:65+63)=mat2gray(s(:,:,5));
a1(129:129+63, 129:129+63)=mat2gray(s(:,:,6));
a1(129:129+63, 193:193+63)=mat2gray(s(:,:,7));
a1(193:193+63, j1:j1+63)=mat2gray(s(:,:,8));
a1(193:193+63, 65:65+63)=mat2gray(s(:,:,9));
a1(193:193+63, 129:129+63)=mat2gray(s(:,:,10));
a1(193:193+63, 193:193+63)=mat2gray(s(:,:,11));
imshow(a1);
i use this part of code to reassemble the watermarked blocks of an image. but it shows the error 'Index exceeds matrix dimensions.
Error in aftrR2 (line 185)
a1(65:65+63, 129:129+63)=mat2gray(s(:,:,2)); ' .
can anyone help me solve the error.thanks in advance.
1 个评论
KSSV
2016-10-17
Check the dimensions of every matrix you are using and see the loop's which you are using to call the matrices.
回答(1 个)
The message means, that the variable "s" does not have the size 2 in the third dimension. Check this:
dbstop if error
Then runm your code again until Matlab stops at the error. Now check the size of the variables unsed in the failing line.
I guess the problem is here:
s = mat2gray(y(:,:,k3));
After the loop "s" is the last gray image, which is a 2D matrix. Then mat2gray(s(:,:,2)) accesses a not existing 3rd dimension and tries to convert it to gray levels again.
0 个评论
此问题已关闭。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!