SAVE A 4D DATA WITH THE BLOCKS STACKED SIDE BY SIDE
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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);
0 commentaires
Réponse acceptée
DGM
le 12 Oct 2022
Modifié(e) : DGM
le 12 Oct 2022
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');
Plus de réponses (1)
Martin Pryde
le 12 Oct 2022
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
Voir également
Catégories
En savoir plus sur Computer Vision with Simulink dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!