Video file of changing solid colors
Mostrar comentarios más antiguos
Hello. I want to create a video file of a solid screen changing colors. I am trying to change the color of the figure systematically through hexcodes and record this as a single video. This will be used ultimately for spectral reflectance recordings of different hexcodes, so I want a single stimulus video displaying one color at a time and changing color after a few seconds. This is the code I have so far, when d is a column of hexcodes. So far, this seems to be changing the background color of an empty plot and only 'recording' the last image to the .mp4. Any help would be appreciated
HexCodes = VideoWriter('\Users\~\Documents\MATLAB\Hexcode_Colors.mp4','MPEG-4');
open(HexCodes);
fig = gcf;
set(gca,'visible','off', 'xtick',[])
H = [0 0 0];
fig = figure('Color', H);
hold;
for i = 1:length(d)
d(i,1)
set(gcf,'color',ans)
pause(.05);
f = getframe;
writeVideo(HexCodes,f);
clf
end
close(HexCodes);
Respuesta aceptada
Más respuestas (1)
darova
el 11 de Sept. de 2019
TRY
HexCodes = VideoWriter('\Users\~\Documents\MATLAB\Hexcode_Colors.mp4','MPEG-4');
HexCodes.FrameRate = 30; % Frames per second (speed of video)
open(HexCodes);
H = [0 0 0];
fig = figure('Color', H);
set(gca,'visible','off', 'xtick',[])
d = jet(100); % create 100 colors of 'jet' colormap
for i = 1:size(d,1)
set(gcf,'color',d(i,:))
pause(.1);
f = getframe;
writeVideo(HexCodes,f);
clf
end
close(HexCodes);
1 comentario
Olivia Harris
el 11 de Sept. de 2019
Categorías
Más información sobre Video Formats and Interfaces en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!