MATLAB: ??? Index exceeds matrix dimensions.

index exceeds matrix dimensions

I think I have a problem with my matrices but I can't figure out where to fix it. The code that I have written is:
??? Index exceeds matrix dimensions.
Error in ==> dctwatermark at 75 dct_block=dct2(cover_object(y:y+blocksize-1,x:x+blocksize-1));

Best Answer

I speculate that your cover_object is not a multiple of blocksize in one (or both) directions, and your code only testing whether the x or y starts in the object instead of testing whether the end would also be in the object.
Related Question