MATLAB Answers

How can concatenate matrices with dimension expansion.

18 views (last 30 days)
Song Juhong
Song Juhong on 19 Apr 2021 at 2:49
Edited: Matt J on 19 Apr 2021 at 3:01
img1 = imread('0.png');
img2 = imread('1.png');
size(img1); % (25, 25)
size(img2); % (25, 25)
I want to make 'img' with its dimension (2, 25, 25)
How can I do it?

Answers (2)

David Hill
David Hill on 19 Apr 2021 at 3:01
Why not 25x25x2?
img(:,:,1) = imread('0.png');
img(:,:,2) = imread('1.png');

Matt J
Matt J on 19 Apr 2021 at 3:00
Edited: Matt J on 19 Apr 2021 at 3:01
permute( cat(3,img1,im2), [3,1,2]);

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by