??? 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!