??? Index exceeds matrix dimensions.
1 回表示 (過去 30 日間)
古いコメントを表示
displayDetectedBlocks('2.jpg',1,1,2) ??? Index exceeds matrix dimensions.
Error in ==> displayDetectedBlocks at 3 pos = pairsVec(booleanDistance==1,1:2);
CODE
function Jt = displayDetectedBlocks(It,blocks,booleanDistance,pairsVec)
pos = pairsVec(booleanDistance==1,1:2);
[m,n] = size(blocks);
[blockSize(1),blockSize(2)] = size(blocks{1,1}.intensity);
Jt = It;
for i=1:size(pos,1)
[K,L] = ind2sub([m,n],pos(i,1));
topLeftPel = blocks{K,L}.topLeftPixel;
Jt(topLeftPel(1):topLeftPel(1)+blockSize(1)-1,topLeftPel(2):topLeftPel(2)+blockSize(2)-1) = ones(blockSize(1),blockSize(2));
end
figure
subplot(121),imshow(It),xlabel('Tampered Image'),
subplot(122),imshow(Jt),xlabel('Potential Tampered Image')
0 件のコメント
回答 (1 件)
Amit
2014 年 1 月 27 日
The error is in line
pos = pairsVec(booleanDistance==1,1:2);
You entered displayDetectedBlocks('2.jpg',1,1,2) and the pairsVec is a scalar or 1X1 matrix. In the line where the error appars, you're trying to access pairsVec's 2nd column which does not exist. That why the error appears.
2 件のコメント
Amit
2014 年 1 月 27 日
You can input pairVec as something like [2 2] That will atleast correct the current error.
However, if you input booleanDistance anything other than 1, it will throw an error again.
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!