1. 首页
  2. 移动开发
  3. 其他
  4. MATLAB图像分块实现方法

MATLAB图像分块实现方法

上传者: 2023-03-11 04:29:03上传 M文件 1009B 热度 40次
% 读取图像
img = imread('image.jpg');
% 图像分块
blockSize = 64;
[M, N, ~] = size(img);
nBlocksX = floor(N/blockSize);
nBlocksY = floor(M/blockSize);
nBlocks = nBlocksX * nBlocksY;
blocks = cell(nBlocks, 1);
idx = 1;
for i = 1:nBlocksY
    for j = 1:nBlocksX
        blocks{idx} = img((i-1)*blockSize+1:i*blockSize, (j-1)*blockSize+1:j*blockSize, :);
        idx = idx + 1;
    end
end
% 显示分块结果
figure;
montage(blocks);
title('MATLAB图像分块实现方法');

用户评论