Home > Mobile >  (Matlab) MovieWriter generates Black White movie from Color Images
(Matlab) MovieWriter generates Black White movie from Color Images

Time:09-17

I want to generate a movie from an image sequence. I used this code:

%% 4.) GENERATE THE MOVIE
disp("Generate the Movie...");
imageNames = dir(fullfile('images','*.png'));
imageNames = {imageNames.name}';
outputVideo = VideoWriter(fullfile('images','AcousticCamera.mp4'),'MPEG-4');
outputVideo.FrameRate = 10;
outputVideo.Quality = 95;
open(outputVideo)
for ii = 1:length(imageNames) %% loop over the images
   img = imread(fullfile('images',imageNames{ii}));
   writeVideo(outputVideo,img)
end
close(outputVideo)

The input images are png color images but the video is black white.

CodePudding user response:

Because you didn't add a profile, it defaults to grayscale. Videowriter Documentation

CodePudding user response:

This was the solution:

...
colorMap = jet(256);
for ii = 1:length(imageNames) %% loop over the images
   img = imread(fullfile('images',imageNames{ii}));
   writeVideo(outputVideo,im2frame(img,colorMap))
end
  • Related