Problem VideoWriter Resizing & Colormap

18 visualizaciones (últimos 30 días)
Jonas Neu
Jonas Neu el 14 de Jun. de 2022
Respondida: Siraj el 31 de Ag. de 2023
Hello,
I have a little problem. I want to convert a picture sequence into a video. I managed that but now I want to change the size of the video frame and the colormap. How can I do that? With "video.Colormap=hot" there is an error: Unrecognized property 'Colormap' for class 'VideoWriter'.
Here my code:
pwd=uigetdir('Open folder with pictures');
cd (pwd)
DirFilesVideo = dir([pwd '/*.jpg']); %hier werden alle Bilder mit der entsprechenden Änderung .bmp gespeichert
video = VideoWriter('video.avi'); %create the video object
%Possible settings
%video.Colormap=hot;
video.Quality = 85;
video.FrameRate=15;
open(video); %open the file for writing
N=numel(DirFilesVideo);
for i=1:N %where N is the number of images
I = uint8(imread(DirFilesVideo(i).name)); %read the next image
writeVideo(video,I); %write the image to file
end
close(video); %close the file

Respuestas (1)

Siraj
Siraj el 31 de Ag. de 2023
Hii! It is my understanding that you want to create a video from all the images stored in a directory.
It is not possible to adjust the height of the video because the “height” property of “VideoWriter” is read-only. The “writeVideo” method sets values for Height and Width based on the dimensions of the first frame.
So, the possible solution for this will be to resize the image before writing it to the video object.
Refer to the following for resizing an image.
To change the colormap use the Colormap” property of the “VideoWriter, but the Colormap property only applies to objects used for writing indexed AVI files. The value of “colormap” needs to be specified as a numeric matrix with three columns and a maximum of 256 rows. Each row in the matrix defines one color using an RGB triplet. An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1].
For example,
video = VideoWriter('video.avi', 'Indexed AVI');
video.Colormap = colormap(hot(256));
For more details on the properties of “VideoWriter” refer to the following,
Hope this helps.

Categorías

Más información sobre Convert Image Type en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by