% 读取图像
img = imread('test.jpg');

% 确定块大小
block_size = [128, 128];

% 分块并显示
figure;
imshow(img);

hold on;
for i = 1:block_size(1):size(img, 1)
    for j = 1:block_size(2):size(img, 2)
        rectangle('Position', [j, i, block_size(1), block_size(2)], 'EdgeColor', 'r');
    end
end
hold off;