如何在MATLAB中重现这个长方体图?

如何在MATLAB中重现这个长方体图?,matlab,3d,plot,Matlab,3d,Plot,我转储了一些视频帧,并希望从中生成一个长方体,如下图所示: 我想知道是否存在一个MATLAB函数来进行这样的绘图?不清楚视频帧的起始格式,因此我假设它们作为电影帧的结构数组加载到MATLAB中(如所述)。我将创建一些示例电影数据(单个图像重复200次),首先向您展示如何将第一帧加载到图像中,以及如何从所有帧的顶边和侧边创建图像(用作长方体的顶边和侧边): 上面的代码假定电影帧与其他帧相反。如果它们是索引图像,则必须从函数中获取附加的colormap参数,然后使用该参数使用函数将图像转换为RGB

我转储了一些视频帧,并希望从中生成一个长方体,如下图所示:


我想知道是否存在一个MATLAB函数来进行这样的绘图?

不清楚视频帧的起始格式,因此我假设它们作为电影帧的结构数组加载到MATLAB中(如所述)。我将创建一些示例电影数据(单个图像重复200次),首先向您展示如何将第一帧加载到图像中,以及如何从所有帧的顶边和侧边创建图像(用作长方体的顶边和侧边):

上面的代码假定电影帧与其他帧相反。如果它们是索引图像,则必须从函数中获取附加的colormap参数,然后使用该参数使用函数将图像转换为RGB图像

接下来,可以使用以下功能将立方体的每一侧打印为纹理贴图曲面:

offset = nFrames/sqrt(2);          %# The offset in pixels between the back
                                   %#   corners and front corners of the
                                   %#   displayed cuboid
surf([0 C; 0 C],...                %# Plot the front face
     [R R; 0 0],...
     [0 0; 0 0],...
     'FaceColor','texturemap',...
     'CData',face1);
hold on;                           %# Add to the existing plot
surf([C C+offset; C C+offset],...  %# Plot the side face
     [R R+offset; 0 offset],...
     [0 0; 0 0],...
     'FaceColor','texturemap',...
     'CData',face2);
surf([0 C; offset C+offset],...    %# Plot the top face
     [R R; R+offset R+offset],...
     [0 0; 0 0],...
     'FaceColor','texturemap',...
     'CData',face3);
axis equal                    %# Make the scale on the x and y axes equal
view(2);                      %# Change the camera view
axis off                      %# Turn off display of the axes
set(gcf,'Color','w'...        %# Scale the figure up
    'Position',[50 50 C+offset+20 R+offset+20]);
set(gca,'Units','pixels',...  %# Scale the axes up
    'Position',[10 10 C+offset R+offset]);
下面是结果图:


对于“长方体”有不同的定义。你能更具体一点吗?你的视频帧是如何存储在MATLAB中的?它们是在电影帧的结构数组中(带有
'cdata'
'colormap'
字段),还是在4-D数组中(例如,一组沿第四维连接的3-D RGB图像),还是其他格式?谢谢。这正是我要找的!最美好的祝福
offset = nFrames/sqrt(2);          %# The offset in pixels between the back
                                   %#   corners and front corners of the
                                   %#   displayed cuboid
surf([0 C; 0 C],...                %# Plot the front face
     [R R; 0 0],...
     [0 0; 0 0],...
     'FaceColor','texturemap',...
     'CData',face1);
hold on;                           %# Add to the existing plot
surf([C C+offset; C C+offset],...  %# Plot the side face
     [R R+offset; 0 offset],...
     [0 0; 0 0],...
     'FaceColor','texturemap',...
     'CData',face2);
surf([0 C; offset C+offset],...    %# Plot the top face
     [R R; R+offset R+offset],...
     [0 0; 0 0],...
     'FaceColor','texturemap',...
     'CData',face3);
axis equal                    %# Make the scale on the x and y axes equal
view(2);                      %# Change the camera view
axis off                      %# Turn off display of the axes
set(gcf,'Color','w'...        %# Scale the figure up
    'Position',[50 50 C+offset+20 R+offset+20]);
set(gca,'Units','pixels',...  %# Scale the axes up
    'Position',[10 10 C+offset R+offset]);