Approaches to create a video in matlab -


what possibilities create videos in matlab? searching , found 3 toolboxes work in field, image processing, image acquisition , control vision... how can without them, create video scratch? i'm interested in various approaches have overview, unable find decent tutorial or consistent source of info on internet.

thanks help!

here of different ways create movies in (core) matlab.

movie2avi

%# figure figure, set(gcf, 'color','white') z = peaks; surf(z);  axis tight set(gca, 'nextplot','replacechildren', 'visible','off');  %# preallocate nframes = 20; mov(1:nframes) = struct('cdata',[], 'colormap',[]);  %# create movie k=1:nframes    surf(sin(2*pi*k/20)*z, z)    mov(k) = getframe(gca); end close(gcf)  %# save avi file, , open using system video player movie2avi(mov, 'mypeaks1.avi', 'compression','none', 'fps',10); winopen('mypeaks1.avi') 

avifile

(deprecated, use videowriter instead)

%# figure figure, set(gcf, 'color','white') z = peaks; surf(z);  axis tight set(gca, 'nextplot','replacechildren', 'visible','off');  %# create avi object nframes = 20; aviobj = avifile('mypeaks2.avi', 'fps',10);  %# create movie k=1:nframes    surf(sin(2*pi*k/20)*z, z)    aviobj = addframe(aviobj, getframe(gca)); end close(gcf)  %# save avi file, , open using system video player aviobj = close(aviobj); winopen('mypeaks2.avi') 

videowriter

%# figure figure, set(gcf, 'color','white') z = peaks; surf(z);  axis tight set(gca, 'nextplot','replacechildren', 'visible','off');  %# create avi object nframes = 20; vidobj = videowriter('mypeaks3.avi'); vidobj.quality = 100; vidobj.framerate = 10; open(vidobj);  %# create movie k=1:nframes    surf(sin(2*pi*k/20)*z, z)    writevideo(vidobj, getframe(gca)); end close(gcf)  %# save avi file, , open using system video player close(vidobj); winopen('mypeaks3.avi') 

imwrite

(technically not movie, animated gif image)

%# figure figure, set(gcf, 'color','white') z = peaks; surf(z);  axis tight set(gca, 'nextplot','replacechildren', 'visible','off');  %# preallocate nframes = 20; f = getframe(gca); [f,map] = rgb2ind(f.cdata, 256, 'nodither'); mov = repmat(f, [1 1 1 nframes]);  %# create movie k=1:nframes     surf(sin(2*pi*k/20)*z, z)     f = getframe(gca);     mov(:,:,1,k) = rgb2ind(f.cdata, map, 'nodither'); end close(gcf)  %# create gif , open imwrite(mov, map, 'mypeaks4.gif', 'delaytime',0, 'loopcount',inf) winopen('mypeaks4.gif') 

Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -