我正在处理图像数据,我有240个图像,每个图像由5个通道贡献,大小231到384.这个矩阵现在大小(240,231,384,5),我希望这个(231 * 240,384, 5)。我不能在不扭曲数据的情况下“重塑”它。我该怎么做?
答案 0 :(得分:0)
这是我对你要做的事情的猜测
test = [1:16]; % sample data
test1 = reshape(test, 4, 4); % rearrange to 4x4
% this has a vertical arrangement which is prob not what you have
[m, n] = size(test1); % get dims
r = 2; % horizontal width / numb of cols
% this prob closer to what you have
test2 = test1(:,1:r)' % flip to horizontal order
test3 = reshape(test2, m*r, 1) % rearrange to vertical
答案 1 :(得分:0)
给出一个矩阵:
n1 = 240; n2 = 231; n3 = 384; n4 = 5;
A = randn(n1, n2, n3, n4);
我想您正在寻求的解决方案是上面Luis所建议的:
B = reshape(A, n1 * n2, n3, n4);
或
C = reshape(permute(A, [2 1 3 4]), n1 * n2, n3, n4);
否则你必须更好地解释你的问题。