MATLAB:将图像分解成图像块,然后撤消此操作

MATLAB: Break up image into image blocks, then undo this operation

我正在使用以下代码行将图像分解为块(子区域):

srhblocks = reshape(permute(reshape(im2, ysrh, ynum, xsrh, xnum), [1 3 2 4]), ysrh, xsrh, xnum * ynum);

x/ysrh 和 x/ynum 是 x/y

中的长度和块数

然后我对每个图像块执行一个操作(每个块输出一个数字)然后想要撤消上面的重塑。你如何执行与上述相反的操作?谢谢

%stitch together search image blocks
srhblocksall = num2cell(srhblocks, [1 2]); %split the stack into a cell array 
srhblocksall = reshape(srhblocksall, ynum, xnum); %reshape the tiles into their final position.
srhblocksall = cell2mat(srhblocksall); %convert to matrix

上面的代码适用于我的应用程序。