ImageGear for C and C++ on Linux v18.10 - Updated
JPEG 2000
User Guide > File Formats and Compressions > File Formats > File Formats Reference > JPEG 2000

Full Name JPEG 2000
Format ID IG_FORMAT_JPEG2K = 100
File Extension(s) *.jp2, *.jpc, *.j2k, *.j2c
Data Type Raster Image
Data Encoding Binary
Color Profile Support Read, Write
Multi-Page Support No
Alpha Channel Support Read/write
ImageGear Platforms Support WIN32, WIN64, Linux 64-bit .NET, .NET64
To support the JPEG 2000 format, attach the ImageGear JPEG 2000 Component to Core ImageGear. See Attaching Components.

ImageGear Supported Versions:

ISO/IEC 15444-1:2000

ImageGear Supported Features:

ImageGear Read Support:

For Raw Codestream JPEG 2000 files:

For JP2-compatible JPEG 2000 files:

ImageGear Write Support:

For Raw Codestream JPEG 2000 files:

For JP2-compatible JPEG 2000 files:

ImageGear Filter Control Parameters:

Filter Control Parameter

Type

Default Value

Available Values

Description

CODE_BLOCK_SIZE

AT_INT32

64

4, 8, 16, 32, 64

Affects image saving.

Nominal code-block dimension. Actual dimension is subject to precinct, tile, and image dimensions.

CODE_BLOCK_STYLE

AT_INT32

IG_JPEG2K_CODE_BLOCK_STYLE_ALL_OFF = 0

enumJPEG2KCodeBlockStyles values.

Affects image saving.

Block coder mode switches. Any combination of values from enumJPEG2KCodeBlockStyles is legal.

DISCARD_LEVELS

AT_INT32

0

Any non-negative integer value.

Affects image loading.

Allows loading a smaller version of the image, which takes less time and memory than loading the whole image. This parameter indicates the number of highest resolution DWT levels which will be skipped during the reading. Dimensions of the image loaded with DISCARD_LEVELS = N will be 2^N times smaller than the actual image dimensions. If the specified number exceeds the number of DWT levels in the image, the lowest resolution level will be loaded. For this parameter to take effect, the image must have more than one DWT level. Use the WAVELET_LEVELS parameter to specify the number of DWT levels for JPEG 2000 image saving.

DISPLAY_OPTIMIZED

AT_BOOL

FALSE

TRUE, FALSE

Affects image loading.

This parameter forces the filter to convert the images to RGB24 format while loading, regardless of the original color space, alpha channels, and bit depth. This may result in faster display of the image, because no colorspace conversions will be used during display.

Note that setting this parameter to TRUE may result in slower image loading, because of the additional conversion applied to rasters during the loading.

EBCOT_BITPLANE_SHIFT

AT_INT32

0

0, 3

This control parameter should be used in combination with the CODE_BLOCK_STYLE control parameter. Setting EBCOT_BITPLANE_SHIFT to 3 and CODE_BLOCK_STYLE to IG_JPEG2K_CODE_BLOCK_STYLE_BYPASS enables a notable encoder speed-up between 10% and 20% over regular coding bypass mode, and a speed-up of up to 40% over regular coding mode. A similar speed-up can be expected in decoding images that have been encoded in this mode.

Images saved in this mode are slightly larger in size but load faster. A value of 0 disables the feature; a value of 3 enables it. The rest of the values are reserved and result in an error upon attempting to set. The feature is disabled by default.

FILE_FORMAT

AT_INT32

IG_JPEG2K_FORMAT_JP2 = 1

enumJPEG2KFormat values.

Affects image saving and metadata updating.

Specifies whether to save the file as a JP2-compatible file or as a raw JPEG 2000 code-stream. JP2 compatible files contain various metadata, such as resolution, color space, palette, XML, etc. Raw code-streams do not store any metadata.

ICC_PROFILE_MODE

AT_INT32

JPEG2K_ICC_PROFILE_LOAD = 0

enumJPEG2KICCProfileModes values.

Specifies the usage mode for ICC profiles embedded into JPEG 2000 images.

MODE

AT_INT32

0

0

This parameter has been deprecated and will be removed from the public API in a future release.

PROGRESSION_ORDER

AT_INT32

IG_JPEG2K_PROGRESSION_ORDER_LRCP = 0

enumJPEG2KProgressionOrders values.

Affects image saving.

This parameter specifies the progression order to be used by the result file. See enumJPEG2KProgressionOrders enumeration for available progression orders.

QUALITY_LAYERS

AT_DOUBLE[]

NULL

NULL or array of non-negative AT_DOUBLE numbers.

Affects image saving.

This parameter represents a more powerful version of the RATE_BYTES control parameter. Its value is an array of one or more bit-rates, expressed in terms of the ratio between the total number of compressed bits in the code stream (including code stream header, but not including JP2 header) and the number of pixels in the image (image width * height). The number of elements in the array represents the number of quality layers. Each value in the array represents the overall bit-rate of this layer, rather than the difference between this layer and the previous layer.

In order to use the maximum quality for the last layer, set the last element of the array to 0.0.

Setting the last element in the array to 0.0 does not guarantee that the image will be saved without a loss of quality. See Saving JPEG 2000 and JPX Images in Lossless Mode for more details.

If some entries of the QUALITY_LAYERS array are very close to each other, and the image is not big, the corresponding quality layers may end up containing no image data.

ImageGear skips creation of empty quality layers. This has no impact on the saved image quality, but slightly reduces the coding time and the saved file size.

Example:

AT_DOUBLE ql[3] = {0.01, 0.1, 0.5};
IG_fltr_ctrl_set(IG_FORMAT_JPEG2K, "QUALITY_LAYERS", ql, sizeof(ql));

If the source image dimensions are 800 x 600 = 480000 pixels, the array used in the example will result in the following layer sizes:

  • 1st layer: 480000 * 0.01 / 8 = 600 bytes
  • 1st and 2nd layers: 480000 * 0.1 / 8 = 6000 bytes
  • 1st, 2nd, and 3rd layers (whole codestream): 480000 * 0.5 / 8 = 30000 bytes

QUANT_STEP

AT_DOUBLE

-1.0

Any negative value; 0.0…2.0

Affects image saving.

This control parameter is the base step size to be used in deriving irreversible quantization step sizes for every sub-band.

Any negative value results in automatic selection of the quantization step size. This is the recommended mode.

RATE_BYTES

AT_INT32

0

Any non-negative integer value.

Affects image saving.

This control parameter specifies the maximal size of the saved code stream in bytes. A zero value instructs the filter to use the highest compression quality.

Using the same non-zero value for different images causes the filter to write files with a different compression rate. In order to provide a consistent compression rate across images of different sizes, calculate this parameter for each image, based on the product of the image width and height, or on the uncompressed DIB size.

Alternatively, use QUALITY_LAYERS control parameter, which uses relative coefficients.

Setting RATE_BYTES to 0 does not guarantee that the image will be saved without a loss of quality. See Saving JPEG 2000 and JPX Images in Lossless Mode for more details.

RESOLUTION_MODE

AT_INT32

IG_JPEG2K_RESOLUTION_MODE_PREFER_DISPLAY = 0

enumJPEG2KResolutionModes

This control parameter specifies the mapping between JPEG 2000 Capture and Display resolutions and ImageGear DIB resolution.

JPEG 2000 format allows storing two sets of resolution information: Capture Resolution and Display Resolution. ImageGear keeps only one set of resolution information for an image. This parameter specifies which resolution from JPEG 2000 image to use as ImageGear DIB resolution, and how to save ImageGear resolution to a JPEG 2000 image.

ImageGear also passes both Capture and Display resolutions to the user as metadata values, regardless of the RESOLUTION_MODE parameter.

The library allows you to save no resolution information, Display Resolution only, or both Display and Capture resolution. It does not allow saving Capture Resolution without saving Display Resolution. If Capture Resolution is known at the time of saving, but Display resolution is not known, the library writes equal values for Display and Capture resolutions.

SAVE_VERSION_INFO AT_BOOL TRUE TRUE, FALSE

Affects image saving and metadata updating.

Unless disabled by setting this parameter to FALSE, ImageGear always inserts its own UUID box with version information into JP2 and JPX files being saved.

It is recommended that you not disable writing the version information, as it could provide helpful hints for future decoders.

STITCH_TILES

AT_BOOL

TRUE

TRUE, FALSE

Affects image loading.

This parameter specifies how tiled images should be loaded. If TRUE then ImageGear loads and stitches (composes together) all tiles automatically into the resulting HIGEAR. If FALSE then ImageGear loads a single tile.

Set this parameter to FALSE in order to load a group of tiles with the help of IG_load_tiles_stitch, IG_load_tiles_stitch_FD, or IG_load_tiles_stitch_mem. If this parameter is TRUE, IG_tile_count_get, IG_tile_count_get_FD, and IG_tile_count_get_mem return {1, 1}, regardless of the actual number of tiles in the image.

TILE_HEIGHT

AT_INT32

0

Any non-negative integer value.

Affects image saving.

Specifies the height of one tile in the reference grid. A zero value indicates the image's height.

TILE_WIDTH

AT_INT32

0

Any non-negative integer value.

Affects image saving.

Specifies the width of one tile in reference grid. A zero value indicates the image's width.

VIEW_HEIGHT

AT_INT32

0

Any non-negative integer value.

Affects image loading.

Allows loading a smaller version of the image, which takes less time and memory than loading the whole image. If the value is nonzero, or is greater than the image height, ImageGear only loads DWT levels whose height is not greater than the parameter value. Dimensions of each decomposition level are twice greater than that of the previous level. A zero value indicates the initial image's height. This parameter is similar to DISCARD_LEVELS in that it allows you to select the highest resolution level for image loading.

VIEW_WIDTH

AT_INT32

0

Any non-negative integer value.

Affects image loading.

Allows loading a smaller version of the image, which takes less time and memory than loading the whole image. If the value is nonzero, or is greater than the image width, ImageGear only loads DWT levels whose width is not greater than the parameter value. Dimensions of each decomposition level are twice greater than that of the previous level. A zero value indicates the initial image's height. This parameter is similar to DISCARD_LEVELS in that it allows you to select the highest resolution level for image loading.

WAVELET_FILTER

AT_INT32

IG_JPEG2K_FILTER_AUTO = -1

enumJPEG2KFilters

Affects image saving.

Specifies the type of Wavelet filter (Auto, Reversible, or Irreversible) to be used for Discrete Wavelet Transform.

Selecting the IG_JPEG2K_FILTER_REVERSIBLE filter does not guarantee that the image will be saved without a loss of quality. See Saving JPEG 2000 and JPX Images in Lossless Mode for more details.

Applying irreversible transform to indexed (paletted) images may result in significant degradation of image quality, because small changes in pixel values may result in significant visual difference after application of a palette. Consider using reversible transform for paletted images, or promoting images to true color and then using the reversible transform.

WAVELET_LEVELS

AT_INT32

-1

-1 … 16

Affects image saving.

Specifies the quantity of decomposition levels (stages) for the image being saved. The main purpose of each level is to provide the ability for the reader to faster decompress the reduced size version of the original image.

Dimensions of the Nth level are 2^N times smaller than the actual image dimensions.

Setting this parameter to -1 tells ImageGear to select the value automatically. Currently, ImageGear uses 5 levels for all types of images in this mode.

Comments:

JPEG 2000 standard defines a compression scheme and a file format for interchange of JPEG 2000 compressed data.

The compression scheme is based on a discrete wavelet transform, and supports both lossy and lossless modes. JPEG 2000 compression is similar to JPEG in that it supports lossy compression. However, JPEG 2000 allows achieving much higher compression ratios while preserving good image quality.

JPEG 2000 file format defines a basic set of features that allow interchange of JPEG 2000 compressed images.