Movies and Data with Matlab Joseph Stover SWIG 10/24/2007.
-
Upload
nataly-gush -
Category
Documents
-
view
220 -
download
0
Transcript of Movies and Data with Matlab Joseph Stover SWIG 10/24/2007.
![Page 1: Movies and Data with Matlab Joseph Stover SWIG 10/24/2007.](https://reader035.fdocuments.us/reader035/viewer/2022062313/56649c765503460f94929f9b/html5/thumbnails/1.jpg)
Movies and Data with Matlab
Joseph Stover
SWIG
10/24/2007
![Page 2: Movies and Data with Matlab Joseph Stover SWIG 10/24/2007.](https://reader035.fdocuments.us/reader035/viewer/2022062313/56649c765503460f94929f9b/html5/thumbnails/2.jpg)
Outline
• Creating and Exporting movies
• Tricks for saving large amounts of data
• Embedding movies in powerpoint or html
• Using Flash
![Page 3: Movies and Data with Matlab Joseph Stover SWIG 10/24/2007.](https://reader035.fdocuments.us/reader035/viewer/2022062313/56649c765503460f94929f9b/html5/thumbnails/3.jpg)
Capturing a Frame
movClip = moviein(numFrames);
for i=1:numFrames;
plotCommand
movClip(i)=getframe;
**or** movClip(i)=getframe(gcf);
end
movie(movClip)
Initialize the movie into memory
make your plot as desired
Save a frame for the movie, this only captures the actual graph
(or) capture a frame including the axes and a grey backgound
Play your movie
![Page 4: Movies and Data with Matlab Joseph Stover SWIG 10/24/2007.](https://reader035.fdocuments.us/reader035/viewer/2022062313/56649c765503460f94929f9b/html5/thumbnails/4.jpg)
Exporting the Moviemovie2avi(movClip, ‘fileName.avi’, ‘compression’, ‘cinepak’)
Matlab movie
File name for export
Compression profile:
‘Cinepak’ or ‘indeo5’ for windows (5 megabytes)
‘none’ for unix (250 megabytes)
movie2avi(movClip, ‘fileName.avi’, ‘compression’, ‘indeo5’, ‘fps’, 15)
Can also specify the frame rate:
![Page 5: Movies and Data with Matlab Joseph Stover SWIG 10/24/2007.](https://reader035.fdocuments.us/reader035/viewer/2022062313/56649c765503460f94929f9b/html5/thumbnails/5.jpg)
Data Saving Tricks
• Use fopen(), fwrite(), fclose() to save data from simulations
• Get rid of excess information by changing data type from float64 to bitn
• Create a script to open data files and plot them to create a movie and export
• Be careful on the size of files and number of files per directory:– 4 KB minimum in Windows (NTFS cluster size), <10,000 per
directory (or crash/slow windows), similar in Unix– Group data into larger files and multiple directories
![Page 6: Movies and Data with Matlab Joseph Stover SWIG 10/24/2007.](https://reader035.fdocuments.us/reader035/viewer/2022062313/56649c765503460f94929f9b/html5/thumbnails/6.jpg)
Data Saving Tricks
For example:
U[i]=(x1, x2, y1, y2, b, u) for i=1:numSteps(large#)
Where x1, x2, y1, y2 are random grid coordinates say…128x128, b = 0 or 1, and u is a random number
* I can save the grid coordinates as bit7 since they are 0:127
* b can be saved as 1 bit.
* u can be saved as float64 (or maybe float32 depending on what resolution I want).
This leads to 93 bits per step, rather than 64 x 6 = 384 bits!
Over 75% savings! Of course it depends on case specifics.
![Page 7: Movies and Data with Matlab Joseph Stover SWIG 10/24/2007.](https://reader035.fdocuments.us/reader035/viewer/2022062313/56649c765503460f94929f9b/html5/thumbnails/7.jpg)
Flash
• Use flash to embed movies in webpages or powerpoint.– Add extra interactivity– High compression– No funny business or problems with seeing
movies on the screen
![Page 8: Movies and Data with Matlab Joseph Stover SWIG 10/24/2007.](https://reader035.fdocuments.us/reader035/viewer/2022062313/56649c765503460f94929f9b/html5/thumbnails/8.jpg)
Flash Example
Slider control
Single frame step
Skip to end, or rewind
Play: reverse or forward
Done with action-scripting, similar to matlab scripts, except with inclusion of timeline and layers
![Page 9: Movies and Data with Matlab Joseph Stover SWIG 10/24/2007.](https://reader035.fdocuments.us/reader035/viewer/2022062313/56649c765503460f94929f9b/html5/thumbnails/9.jpg)
Flash Example
• This example was:– 90MB compressed with indeo5– 8.4MB compressed with AutoGK– 9.1MB with flash(including interactivity)
• 2 separate movies merged together due to memory using “VirtualDub”
![Page 10: Movies and Data with Matlab Joseph Stover SWIG 10/24/2007.](https://reader035.fdocuments.us/reader035/viewer/2022062313/56649c765503460f94929f9b/html5/thumbnails/10.jpg)
Embedding flash in HTML
<object width="300" height="600">
<param name="movie" value="16x16Model2.swf">
<embed src="16x16Model2.swf" width="300" height="600">
</embed>
</object>
![Page 11: Movies and Data with Matlab Joseph Stover SWIG 10/24/2007.](https://reader035.fdocuments.us/reader035/viewer/2022062313/56649c765503460f94929f9b/html5/thumbnails/11.jpg)
On your phone?
• Use IVC – “Internet Video Converter” to compress for your phone, an easy way to show your work
• Compresses to 3gp, mpeg, avi, and many other formats
![Page 12: Movies and Data with Matlab Joseph Stover SWIG 10/24/2007.](https://reader035.fdocuments.us/reader035/viewer/2022062313/56649c765503460f94929f9b/html5/thumbnails/12.jpg)
AutoGK & VirtualDub
• Free program “Auto Gordian Knot”
• Compresses movies• Merges clips
![Page 13: Movies and Data with Matlab Joseph Stover SWIG 10/24/2007.](https://reader035.fdocuments.us/reader035/viewer/2022062313/56649c765503460f94929f9b/html5/thumbnails/13.jpg)
Conclusion
• Any questions?