The problem comes when MATALB tries to evaluate the function for the corner blocks. If you go into the blockproc
function, you can observe that the error occurs because the getBlock
function returns a 3x1
block (?). Therefore, you should set PadPartialBlocks
to true.
Blocksize = 3;
fun = @(block) block.data .* im2(1:Blocksize, 1:Blocksize);
im3 = blockproc(im1,[Blocksize Blocksize],fun, 'PadPartialBlocks',1,'TrimBorder', 1);
Also, you mention that you want to multiply with the top right block but in fact you are accessing the top left block.