Creating a Motion JPEG2000 Animation

To create a Motion JPEG2000 file, create a new IDLffMJPEG2000 object and set the WRITE property equal to 1. During initialization, you must specify a filename, which is the path and location of the MJ2 file to be created.

Note
If you specify an existing MJ2 file as the Filename argument during initialization, and also set the WRITE keyword, the existing file will be overwritten without prompting and all existing data will be replaced with the new data. It is not possible to append data to an MJ2 file.

To create a file, you will need to use the IDLffMJPEG2000::SetData and IDLffMJPEG2000::Commit methods. The SetData method lets you add entire frames of data, or individual frame components or frame tiles to the MJ2 file. However, before the first call to SetData, there are several properties you may need to set.

Table 6-1: Properties that Must be Set Before Calling the SetData Method

Property
Brief Description

BIT_DEPTH

Specifies the bit depth of the data to be written to the file. If not set, the default value of 8 will specify byte data.

Note - To write short or long integer data, you must set the BIT_DEPTH and SIGNED properties before calling SetData.

COMMENT

Specifies a descriptive comment for the file.

FRAME_BUFFER_LENGTH

Defaults to 3, the number of frame slots in the frame buffer. See High Speed MJ2 Reading and Writing for information on how modifying this value can enable high-speed reading and writing of MJ2 files.

N_LAYERS

Defines the number of quality levels used to build the frame. If not set, the default value (1) is used.

N_LEVELS

Defines the number of wavelet decompression levels. The default is 5 unless the PALETTE property is set, in which case the default is 0.

PALETTE

Set to a 3-by-n or an n-by-3 array of byte or integer values where n is the number of intensity values for the three (r, g, b) color channels.

REVERSIBLE

Set to 1 (lossless) to be able to retrieve the original data. The default is 0 (lossy) unless the PALETTE property has been set.

SIGNED

Set to 1 to write signed data. Otherwise, data will be written as unsigned (0, the default).

The following properties will be automatically set based on the first frame of data passed to SetData if not specified before the first call. If you are passing in a single frame component or tile component in each call to SetData, you need to set the related properties (N_COMPONENTS or TILE_DIMENSIONS) prior to the first call to SetData in order for the data to be written to the file correctly.

Table 6-2: Properties Set Based on SetData Input if Not Specified

Property
Description

COLOR_SPACE

Defines the color space of the file. If the input data has 1 component, the default is monochrome; if it has 3 components, the default is RGB (unless the YCC property is set).

DIMENSIONS

Defaults to the width, height of the first frame of input data. The dimensions of each data array must match.

N_COMPONENTS

Defaults to the number of components in the first frame.

TILE_DIMENSIONS

Defaults to the DIMENSIONS of the frame if not set.

Note
See "IDLffMJPEG2000 Properties" (IDL Reference Guide) for details.