AVI Creating AVI & MPEG Movies Jessica Ewing. 2 Goals To write Matlab code that will create a movie...
-
Upload
roderick-powers -
Category
Documents
-
view
215 -
download
2
Transcript of AVI Creating AVI & MPEG Movies Jessica Ewing. 2 Goals To write Matlab code that will create a movie...
Creating AVIAVI & MPEG Movies
Jessica Ewing
2
Goals• To write Matlab code that will create a movie matrix which stores the images of the diffusion of the concentration frame by frame
• To create a Matlab movie using the matrix we create and the Matlab command movie( )
• To save this movie as an AVI file as well as an MPG file
3
The codecreatemoviematrix.m
• This code is made by using the code for plotconcentrationlevelk.m
• Just insert the following line of code in Nadine’s code in the for loop…it should look like this:
• …
• Spy(Nadine2, ‘g.’);
• Hold off;
• Jessica(k)=getframe;
• …
4
The code continued
• The new line of code uses the getframe function, which stores each frame created in the for loop into the movie matrix Jessica
• Note: Since the for loop runs for k=1: (Concentration,2), that means that there will be “ntimes” number of frames
• Thus to adjust the number of frames, we need to change the values of Nadine’s variables ( deltat and time) in her code for concentrate.m
5
Making a movie in Matlab
• First we must run:load a5;
preprocess;
nbfind;
CalculateVelocityDomain;
v=w\rhs;
posprocessflow;
plotnormalizedvelocityfield;
concentrate;
createmoviematrix;
6
Movie function
• We can now run: movie(Jessica);
which will create a Matlab movie using our movie matrix Jessica
• Problem: We can only look at this movie while in Matlab…meaning it is not savable.
• Solution: Let’s make AVI and MPG files of our movie and then we can watch it anytime!!
7
AVI Files• It is easy to make an AVI file using Matlab,
however you need to have Matlab 6• In Matlab, you can type help movie2avi for
information on the movie2avi function• To use the movie2avi function you need to follow
the following convention:movie2avi( mov, filename, param, value, param...)
• So in our case, we will type:movie2avi( Jessica, ‘JessicaAVI’, ‘quality’,100);
• This will save an AVI movie named JessicaAVI in your current directory
8
AVI Files continued
• Problem: We receive streaks in our AVI movie in the blue regions of our image of the gulf
• Solution: Who knows? When you look in the help Matlab gives for movie2avi there are several parameters you can specify…there may be a solution here, but I couldn’t find it
• Colormap may be part of the solution:
go to help colormap in matlab
9
MPG Files:ftp://ftp.mathworks.com/pub/contrib/v5/graphics/mpgwrite/
• Before we can even begin to make a MPG file we need to go to the above website and download the following into our current directory:1. Mgpwrite.dll2. Mpgwrite.doc
• The .dll file is our executable and the .doc file explains how the function mpgwrite( ) works
• So now we can type the following in Matlab to create our MPG movie:mpgwrite(Jessica,[], ‘Jessica.mpg’,[0,0,1,0,5,8,10,10]);
10
MPG Files continued
• The previous Matlab command will create a movie named Jessica.mpg and store it in our current directory
• Problem: Again, our movie is not as clear as we would like. The string of numbers in the command specify the values of the various parameters described in the .doc file…so possibly getting a different combination will result in a clearer picture.
• Also, the issue of the colormap comes up here…the [ ] in the command line refers to the colormap, and since we don’t have one we are forced to use the empty set
11
Conclusion
• We now have movies showing the diffusion of the concentration of the spill in the Gulf of Mexico that we can view anytime
• To view the movies, just click on the file and your computer will view it with the appropriate program (ie Media Bar, etc)
• Possibly creating a colormap will help with the clarity of these movies