| Customize Help

Working with tables



In some applications, the default quantization or Huffman tables might not be suitable. MIL allows you to create your own. You can inquire the default table values to help you determine appropriate values. You might have to select values by trial and error to determine the best ones for your application.

For JPEG2000 compression, quantization multiplies coefficients, while in JPEG compression, quantization divides values.

Whether you are inquiring the default tables or customizing your own, you must allocate arrays that are large enough to contain the data. The table below lists the tables that you can manipulate and their required array size for each compression algorithm.

Compression algorithm

Table type

Buffer type, size, and attribute

JPEG lossless

DC Huffman

1-dimensional, 8+ M_UNSIGNED, 28 entries, M_ARRAY

JPEG lossy

DC Huffman

1-dimensional, 8+ M_UNSIGNED, 28 entries, M_ARRAY

AC Huffman

1-dimensional, 8+ M_UNSIGNED, 178 entries, M_ARRAY

Quantization

2-dimensional, 8+ M_UNSIGNED, 8x8 entries, M_ARRAY

JPEG2000 lossy

Quantization

1-dimensional, 32+ M_FLOAT, 3 N + 1 entries, where N is the number of decomposition levels, M_ARRAY

Note that during development and at runtime, compression support is reliant upon the presence of a compression/decompression package license. This license is only included by default with the development dongle for the full version of MIL. In other cases, this license must be purchased separately.

Inquiring values in default tables

Inquiring the default values of a table is useful to determine values for your custom tables. The steps below outline this procedure.

  1. First, inquire the MIL identifier of the default table using MbufInquire(). Then, inquire the size of the table using the same function.

  2. Allocate a user array of the appropriate size for storing the default table values.

  3. Get the values from the inquired table in Step 1 and store them in the user array using MbufGet...().

Using your own table

To use your own table:

  1. Allocate a buffer with an M_ARRAY attribute and of the same data type as the default table.

  2. Transfer the custom table values from the user array to the array buffer, using MbufPut...(), depending on the type of table.

  3. Associate the M_ARRAY buffer to the required M_COMPRESS image buffer, using the MbufControl() control types specific to your table (for example, use the M_HUFFMAN_AC control type for an AC Huffman table). Specifying these control types as-is, or combined with M_ALL_BANDS, controls all bands for JPEG2000. This is the default setting.

    For a JPEG2000 compression, you can associate a different table with each band of a multi-band buffer. To do so, add M_RED, M_BLUE, or M_GREEN to your control type for an RGB buffer, whereas for a YUV buffer, add M_Y, M_U, or M_V.

    For JPEG lossy compressions of YUV buffers, use the luminance and chrominance control types. The control types without these suffixes control all bands.

If you set the M_Q_FACTOR control type after specifying a custom table, the custom table will be scaled.