How to make a flashing movie? Please suggest any approach without application of any specific toolbox.

1 view (last 30 days)
I am willing to make a video consists of 2 parts that are flashing and steady. The flashing could be in shape i.e circle or triangle. I created circle and dark with the following:
xCenter = 5;
yCenter = 6;
theta = 0 : 0.01 : 2*pi;
radius = 3;
x = radius * cos(theta) + xCenter;
y = radius * sin(theta) + yCenter;
plot(x, y);
fill(x,y,'k');
axis square;
xlim([0 10]);
ylim([0 12]);
axis equal;
set(gca,'Color','k')
And I want the flashing to continue for 17 seconds and steady for 17 seconds repeating 10 times each.

Accepted Answer

Geoff Hayes
Geoff Hayes on 5 May 2020
Yanjinsuren - do you really mean to create a movie (say with videowriter) or do you just want to have the circle alternate between black (on the black background) and white as per your requirements? To get you started on those, just keep the handle to the fill object, and change it's colour every one second. Something like
hFill = fill(x,y,'k');
axis square;
xlim([0 10]);
ylim([0 12]);
axis equal;
set(gca,'Color','k')
% use colour array [0 0 0] for black
color = [0 0 0];
set(hFill,'FaceColor',color);
for j = 1:10
for k = 1:17
% alternate between black [0 0 0] and white [1 1 1]
set(hFill,'FaceColor',mod(get(hFill,'FaceColor') + 1, 2));
pause(1.0);
end
pause(17);
end
Start with the above and try adding the video writer as needed.
  2 Comments
Yanjika O
Yanjika O on 5 May 2020
Edited: Yanjika O on 5 May 2020
Thank you Geoff. That is exactly what I was trying to explain. Let`s say I call those alternating flash as my first trial and what if I want to have the inter-trial period of complete black for 60 seconds between 2 consecutive trials?
Geoff Hayes
Geoff Hayes on 5 May 2020
Just pause for sixty seconds between trials if you want all black:
for k = 1:17
% alternate between black [0 0 0] and white [1 1 1]
set(hFill,'FaceColor',mod(get(hFill,'FaceColor') + 1, 2));
pause(1.0);
end
set(hFill,'FaceColor',[0 0 0]);
pause(60);
end

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB Support Package for IP Cameras in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!