我正在尝试将多维数组 reshape 为原始图像。我使用我找到的出色解决方案将 512x512 像素的图像拆分为 8x8 像素的子矩阵 in this question :
sub_images = permute(reshape(permute(reshape(i_image, size(i_image, 1), n, []), [2 1 3]), n, m, []), [2 1 3]);
在这种情况下 n=m=8 并且 sub_images 是一个 8x8x4096 的数组。现在的问题是我想回到原始图像以避免 for 循环,但我不知道该怎么做。我知道存在函数 colfilt
或 blockproc
但我不能使用它们。非常感谢任何帮助!
最佳答案
只需执行与您用于 reshape 原始数组的操作相反的操作。置换命令保持不变(切换第一维和第二维),而 reshape 命令回到 512
reshaped_i_image = reshape(permute(reshape(permute(sub_images, [2 1 3]), 8, 512, []), [2 1 3]), 512, 512);
关于Matlab reshape 回原始图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30738347/