k-Wave Toolbox Previous   Next

Saving Movie Files Example

Overview

This example demonstrates how to save the simulation animations as a movie. It builds on the Heterogeneous Propagation Medium Example.

 Back to Top

Setting the 'RecordMovie' flag

In the preceeding example, the optional input 'PlotLayout' was used to change the default behaviour of kspaceFirstOrder2D. Here several other optional inputs are used to save the simulation animation to a movie file. By setting 'RecordMovie' to true the displayed image frames are saved and exported as a movie with a date and time stamped filename. A user defined filename can also be given by setting the 'MovieName' input to an arbitrary string. The movie frames are captured using im2frame and converted using movie2avi thus the size of the movie will depend on the size of the simulation grid.

% set the input arguements
input_args = {'PlotLayout', true, 'RecordMovie', true, 'MovieName', 'example_movie'};

% run the simulation
sensor_data = kspaceFirstOrder2D(p0, kgrid, c, rho, 'auto', sensor_mask, input_args{:});

 Back to Top

Controlling the movie settings

As the movie frames mimic those used for the simulation animation, the output can be controlled by changing the animation settings. The image scaling can be set using 'PlotScale', and the number of iterations which must pass before the simulation plot is updated can be controlled via 'PlotFreq'. Note, the default color map used for the animation has zero set to white (see getColorMap), thus using a scaling parameter set to [-a, a] will give the best visual results.

% set the input arguements
input_args = {..., 'PlotScale', [-2, 2], 'PlotFreq', 5, ...};

Optional inputs can also be passed directly to movie2avi via 'MovieArgs'. An example of changing the default frame rate is given below.

% set the input arguements
input_args = {..., 'MovieArgs', {'fps', 30}, ...};

Note, by default k-Wave sets 'Compression' to 'Cinepak' for 32-bit Windows, and 'None' for 64-bit Windows and Unix.

 Back to Top


© 2009 Bradley Treeby and Ben Cox.