【问题标题】:MATLAB: Break up image into image blocks, then undo this operationMATLAB:将图像分解为图像块,然后撤消此操作
【发布时间】:2016-01-18 01:08:59
【问题描述】:

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

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

x/ysrh 和 x/ynum 是 x/y 中块的长度和数量

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

【问题讨论】:

  • 您是否必须重塑图像才能进行计算,或者只需获取计算的子区域并将图像保留原样就足够了吗?
  • im 的大小是多少?此处不使用blocproc 的具体原因?您的计算输出的大小是多少?您期望最终结果的大小是多少?
  • size(im2) = 357 x 441。这会生成 119x49x27 像素的 srhblocks,因此有 27 个 119x49 像素块。我想用 9(x) x 3(y) 2D 图像将其重塑为 3D 堆栈
  • 我相信我不能使用 blocproc,因为我正在使用每个子区域块计算归一化的互相关。
  • @2one - 当然可以。只需向blockproc 提供一个匿名函数来计算每个块的归一化互相关吗?

标签: matlab reshape permute


【解决方案1】:
%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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-11
    相关资源
    最近更新 更多