我想在最后添加一个3d矩阵到4D矩阵: 像这样:
v=VideoReading('video.avi');
mat3d = zeros([n m 3],'double');
mat4d = zeros([n m 3 2],'double');
for i=1:10
mat3d = read(v,i);
mat4d = ????;
end
l=size(mat4d);
我想在mat4d中添加10帧,l = [n m 3 12]
答案 0 :(得分:1)
要获得这些帧的最具体的10个,你需要输入这样的命令:
#include <stdio.h>
int main (void)
{
int i = 0, j = 0;
int sbox [256];
int key [32];
char *key_str = "abcdefghijklmnopqrstuvwxyz";
int tmp = 0;
int n = 0;
fprintf (stdout,"Key string is %s\n",key_str);
for (i=0; i<32; i++)
{
key[i] = key_str[i%5];
sbox[i] = i;
}
j = 0;
for (i=0; i<32; i++)
{
j += sbox[i] + key[i];
j = j % 32;
tmp = sbox[i];
sbox[i] = sbox[j];
sbox[j] = tmp;
}
i = 0;
j = 0;
for (n=0; n<10000; n++)
{
i++;
i = i % 32;
j += sbox[i];
j = j % 32;
tmp = sbox[i];
sbox[i] = sbox[j];
sbox[j] = tmp;
if ((n == 0) || (n == 99) || (n == 999) || (n == 9999))
{
fprintf (stdout,"byte %d is %0x00\n",
n+1,sbox[(sbox[i] + sbox[j]) % 32]);
}
}
return (0);
}
答案 1 :(得分:1)
我刚刚找到解决方案:
mat4d(:,:,:,i) = mat3d;
很简单!