How can I create a video from a 3D matrix that is not in rgb format?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Keanu Guardiola Flores
el 13 de Feb. de 2018
Respondida: Melika Bahmanabasdi
el 8 de Mayo de 2020
I have a matrix of the form : M = 10*rand(4,4,10);
where each a_ij element represents the position of a physical thing, and its value represent its intensity. The third coordinate is time. I want to see how each element behaves in time, so I want to take each 4x4 slice and convert it to a video frame, and all of them should share the same limits for the colormap/colorbar. I say this because the actual data I have does not share the same min and max values at each 4x4 slice, and I want to keep these fixed to the min and max of the whole 3D matrix. I've tried many things such as converting each slice to rgb image, but I don't know how to set the color scale to be the same for all slices instead of having one different for each slice.
I would greatly appreciate it if someone could point me in the right direction as to how to do this.
Also, given the great amount of data I would like to convert them to video frames without having to save each image to my computer.
0 comentarios
Respuestas (1)
Melika Bahmanabasdi
el 8 de Mayo de 2020
%****************** Convert Tensor to video ****************************
VidObj = VideoWriter('movie.avi','Grayscale AVI'); %set your file name and video compression
VidObj.FrameRate = 1; %set your frame rate
open(VidObj);
for f = 1:size(T, 3)
writeVideo(VidObj,mat2gray(T(:,:,f)));
end
close(VidObj);
%******************************** End *********************************
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!