如何在Matlab中从3D矩阵制作视频 [英] How to make a video from a 3d matrix in matlab
问题描述
我在matlab中有一堆2D矩阵(它们应该组成一个3D矩阵,其中第3维是时间),我正在尝试从图像数据制作视频.
I have a whole bunch of 2D matrices in matlab (they're suppose to make up a 3D matrix where the 3rd dimension is time), and I'm trying to make a video from the image data.
我知道我可以使用surf()使用2D矩阵之一制作表面图,但是我不确定要调用哪个命令来获取所有2D矩阵并将它们转换为表面图的视频
I know that I can use surf() to make a surface plot using one of the 2D matrices, but I'm not sure which command to invoke to take all my 2D matrices and convert them into a video of the surface plot.
任何人都可以帮忙吗?
推荐答案
The built-in function immovie(X,map)
is one option for what you want. This function expects a m-by-n-by-1-by-k
4D matrix, where the 4th dimension is the frames of the movie. Since you're starting with a 3D matrix, use permute first:
Orig; % 3D matrix
X = permute(Orig,[1 2 4 3]); % 4D matrix
movie = immovie(X,map); % map is the colormap you want to use
implay(movie);
这篇关于如何在Matlab中从3D矩阵制作视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!