SAVE A 4D DATA WITH THE BLOCKS STACKED SIDE BY SIDE

3 ビュー (過去 30 日間)
Eberechi ICHI
Eberechi ICHI 2022 年 10 月 11 日
コメント済み: Eberechi ICHI 2022 年 10 月 12 日
Please i need your assistance to complete this code.
Y_pred_1 is a 32x32x2x663 data.
I wanted to extract the 32x32x1 for all the 663 blocks and convert them to an image with size 416x1632 where the 32x32 blocks are stacked side by side along the rows to form the final image (416x1632).
The final output B13 is stacking each column of B12 vertically and not rather the block horizontally.
n=size(Y_pred_1, 4)
for i = 1:n;
pred_1(:,:,1,i) = Y_pred_1(:,:,1,i);
end
B1 = reshape(pred_1, [], size(Y_pred,4));
B12 = reshape(B1, [32,32,663]);
B13=reshape(B12,416,1632);

採用された回答

DGM
DGM 2022 年 10 月 12 日
編集済み: DGM 2022 年 10 月 12 日
Alternatively, you could use IPT imtile().
A = rand(32,32,2,663); % initial 2-channel multiframe image
B = imtile(A(:,:,1,:),'gridsize',[NaN 51]); % tiled composite of first channel
Note that imtile() always tiles the frames in a row-wise fashion. If that weren't your requirement, using imtile() would get more cumbersome.
MIMT has a similar tool of the same name, but it doesn't have the same limitation. With MIMT imtile(), you could just explicitly specify the tiling direction:
C = imtile(A(:,:,1,:),[NaN 51],'direction','col');
  1 件のコメント
Eberechi ICHI
Eberechi ICHI 2022 年 10 月 12 日
This works perfectly. Thanks

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

その他の回答 (1 件)

Martin Pryde
Martin Pryde 2022 年 10 月 12 日
It would be helpful if you could provide example data for Y_pred_1.
MATLAB arranges all 2D and multidimensional rows first hence why your blocks are stacking vertically. Input your horizontal resolution as your first dimension and simply transpose the result (B13 = reshape(B12,1632,416).';).
On the otherhand, the description you provided reads to me like your code would be more readable and terse if you used cells.
Y_pred_1 = rand(32,32,2,663); % your data
bar = cell2mat(reshape(num2cell(squeeze(Y_pred_1(:,:,1,:)),[1,2]),1632/32,[])).'; % your image
  1 件のコメント
Eberechi ICHI
Eberechi ICHI 2022 年 10 月 12 日
Thanks, this works but transposed the 32x32 image.

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

カテゴリ

Help Center および File ExchangeComputer Vision with Simulink についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by