How to make video from a 3d matrix in Matlab

I have a whole bunch of 2D matrices in matlab (they should make a three-dimensional matrix, where the 3rd dimension is time), and I'm trying to make a video from image data.

I know that I can use surf () to create a surface graph using one of the 2D matrices, but I'm not sure which command to call to take all my 2D matrices and convert them to a video image.

Can anyone help?

+4
source share
1 answer

The built-in immovie (X, map) function is one option for what you want. This function expects the m-by-n-by-1-by-k 4D matrix, where the 4th dimension is the frames of the film. Since you start with a three-dimensional matrix, first use the permute command:

 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); 
+5
source

Source: https://habr.com/ru/post/1480617/


All Articles