Segment the image into blocks

只愿长相守 提交于 2019-11-28 02:17:21

Try using mat2cell to break the image up into blocks:

bsX = 10; bsY = 10;
[m,n] = size(Y);
numFullBlocksX = floor(n/bsX); numFullBlocksY = floor(m/bsY);
xBlocks = [repmat(bsX,numFullBlocksX,1); mod(n,bsX)*ones(mod(n,bsX)>0)];
yBlocks = [repmat(bsY,numFullBlocksY,1); mod(m,bsY)*ones(mod(m,bsY)>0)];
blockCell = mat2cell(Y,yBlocks,xBlocks)

To instead go from number of blocks to block size, lead with these two lines instead of bsX = 10; bsY = 10;:

numBlocksX = 10; numBlocksY = 10;
bsX = ceil(n/numBlocksX); bsY = ceil(m/numBlocksY);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!