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.
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.
Can anyone help?
I = mat2gray( A , [amin amax] ) converts the matrix A to a grayscale image I that contains values in the range 0 (black) to 1 (white). amin and amax are the values in A that correspond to 0 and 1 in I . Values less than amin are clipped to 0, and values greater than amax are clipped to 1.
Conversion of a Matrix into a Row Vector. This conversion can be done using reshape() function along with the Transpose operation. This reshape() function is used to reshape the specified matrix using the given size vector.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With