I = imread('../../Downloads/Mona_Lisa_headcrop.jpg');
I = imresize(I, 1/20);
n = 10;
Nsteps = 10;
filename = 'test.avi';
col = I(1, 1, :);
col = uint8(fix(double(intmax(class(I)))*rand(1,1,3)));
B = repmat(col, [size(I,1), size(I, 2)]);
what_to_do = 'test';
what_to_do = 'create video';
if strcmp(what_to_do, 'create video')
v = VideoWriter(filename);
open(v)
end
for s = linspace(1/n, 1, Nsteps)
Is = imresize(I, s);
ij = round((size(B) - size(Is))/2);
Ii = B;
Ii(ij(1) + (1:size(Is,1)), ij(2) + (1:size(Is,2)), :) = Is;
switch what_to_do
case 'test'
imshow(Ii), axis off
disp('press key for next frame')
pause
case 'create video'
imshow(Ii), axis off
writeVideo(v, getframe(gcf));
otherwise, error('Unknown method.')
end
end
if strcmp(what_to_do, 'create video')
close(v)
end
disp('Press return to playback video')
pause
if strcmp(what_to_do, 'create video')
v = VideoReader(filename);
ax = axes;
ax.Visible = 'off';
while hasFrame(v)
F = readFrame(v);
image(F, 'Parent', ax);
ax.Visible = 'off';
pause(1/v.FrameRate);
end
clear v
end
0 Comments
Sign in to comment.