MATLAB: How to divide gray scale image into 8×8 blocks and access each block separately to apply dct2 on the block

binarydctdividegrayscale

I want to divide the grayscale image which in my case is the 'cameraman.tif' into 8×8 blocks then run dct2 on each block to
later hide a binary watermark image into each block.
So far I tried blockproc and many other methods but none of them satisfy my needs.

file = 'cameraman.tif';im=imread(file);imshow(im);
imModified = blockproc(im,[8 8],@(blkStruct) dct2(blkStruct.data));imshow(imModified)