Matlab reshape in 3D

11 ビュー (過去 30 日間)
2one
2one 2015 年 10 月 20 日
コメント済み: 2one 2015 年 10 月 20 日
I have a 119 x 49 x 27 (yxz) matrix (A) which is a stack of 27 blocks which make up a larger 2D image. I know that the larger 2D image has 3 x 9 (yx) =27 blocks. I am trying to 'stitch' together the 27 blocks to make the larger image. So far I've got:
B = reshape(A,49*9,119*3);
It generates a 2D matrix B (441 x 357) but is not correct.
  1 件のコメント
2one
2one 2015 年 10 月 20 日
it seems that the order than it joins the 27 blocks together is incorrect.

サインインしてコメントする。

採用された回答

Guillaume
Guillaume 2015 年 10 月 20 日
I'm not sure it can be done with reshape and permute alone. Temporarilly using a cell array, it's very easy:
A = permute(repmat(1:27, [119 1 27]), [1 3 2]); %demo matrix
B = num2cell(A, [1 2]); %split the stack into a cell array
B = reshape(B, 3, 9); %reshape the tiles into their final position. You may need to transpose the reshape
B = cell2mat(B); %convert to matrix
  1 件のコメント
2one
2one 2015 年 10 月 20 日
Thanks! works beautifully!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by