FILEJ2KOPTIONS

typedef struct _FILEJ2KOPTIONS
{
   L_INT nSize;
   L_BOOL bUseColorTransform; 
   L_BOOL bDerivedQuantization; 
   J2KCOMPRESSIONCONTROL uCompressionControl;
   L_FLOAT fCompressionRatio;
   L_UINT32 uTargetFileSize; 
   L_UINT32 uXOsiz;
   L_UINT32 uYOsiz;
   L_UINT32 uXTsiz;
   L_UINT32 uYTsiz;
   L_UINT32 uXTOsiz;
   L_UINT32 uYTOsiz;
   L_UINT32 uXRsiz [J2K_MAX_COMPONENTS_NUM]; 
   L_UINT32 uYRsiz [J2K_MAX_COMPONENTS_NUM];
   L_UINT uDecompLevel;
   L_UINT uProgressOrder;
   L_INT nCodBlockWidth;
   L_INT nCodBlockHeight;
   CODBLOCKSTYLE CodBlockStyleFlags;
   L_UINT uGuardBits;
   L_INT nDerived_Base_Mantissa;
   L_INT nDerived_Base_Exponent;
   L_BOOL bUse_SOP_Marker;
   L_BOOL bUse_EPH_Marker;
   J2KREGIONOFINTEREST uROIControl;
   L_BOOL bUseROI;
   L_FLOAT fROIWeight;
   RECT rcROI;
} FILEJ2KOPTIONS, L_FAR * pFILEJ2KOPTIONS;

The FILEJ2KOPTIONS structure provides information for JPEG 2000 compression options.

Member

Description

nSize

Size of this structure.

bUseColorTransform

Flag that indicates whether to convert an RGB image to YUV space before compressing. (YUV space provides greater compression with higher image quality.) Possible values are:

 

Value

Meaning

 

TRUE

Convert to YUV space before compressing. (Default)

 

FALSE

Do not convert to YUV space before compressing.

bDerivedQuantization

Flag that indicates whether to use derived quantization or expounded quantization. Possible values are:

 

Value

Meaning

 

TRUE

Use derived quantization.

 

FALSE

Use expounded quantization.

 

uCompressionControl

Flag that indicates how to determine the resulting compression. The value of this members determines which structure member should be used for determining the compression. Possible values are:

 

Value

Meaning

 

J2K_COMPRESSION_RATIO

Compress the image based on the value of the fCompressionRatio member.

 

J2K_COMPRESSION_TARGETSIZE

Compress the image based on the target image size in the uTargetFileSize member.

 

J2K_COMPRESSION_QFACTOR

Compress the image based on the quality factor passed to any of the functions, which can be used to replace or insert image(s) in the Pixel Data Element.

fCompressionRatio

Value that indicates the compression ratio to use. This value is used only if the uCompressionControl member is set to J2K_COMPRESSION_RATIO.

uTargetFileSize

Value that indicates the size of the target JPEG 2000 stream, in bytes. This value is used only if the uCompressionControl member is set to J2K_COMPRESSION_TARGETSIZE.

uXOsiz

Horizontal offset from the origin of the reference grid to the left side of the image area.

uYOsiz

Vertical offset from the origin of the reference grid to the top of the image area.

uXTsiz

Width of one reference tile, with respect to the reference grid.

uYTsiz

Height of one reference tile, with respect to the reference grid.

uXTOsiz

Horizontal offset from the origin of the reference grid to the left side of the first tile.

uYTOsiz

Vertical offset from the origin of the reference grid to the top of the first tile.

uXRsiz

Reserved.

uYRsiz

Reserved.

uDecompLevel

Number of resolution levels in the compressed file. The maximum number of levels depends on the size of the image. Passing values that are too large will cause the save operation to fail. Each resolution level is one-half the size of the previous resolution, starting with the full image resolution. The default value is 5.

uProgressOrder

Indicates the order of progression. Possible values are:

 

 

Value

Description

 

J2K_LAYER_RESOLUTION_COMPONENT_POSITION

[0] Quality–axis order.

 

J2K_RESOLUTION_LAYER_COMPONENT_POSITION

[1] Resolution-axis order.

 

J2K_RESOLUTION_POSITION_COMPONENT_LAYER

[2] Resolution-axis order.

 

J2K_POSITION_COMPONENT_RESOLUTION_LAYER

[3] Position–axis order.

 

J2K_COMPONENT_POSITION_RESOLUTION_LAYER

[4] Color-axis order.

 

nCodBlockWidth

Width of the code block, following wavelet transformation. The value must be a power of 2. It must be at least 4 and less than or equal to 1024.

nCodBlockHeight

Height of the code block, following wavelet transformation. The value must be a power of 2. It must be at least 4 and less than or equal to 1024.

CodBlockStyleFlags

Bit flags that indicate the behavior of the code block. For more information, refer to the CODBLOCKSTYLE structure.

uGuardBits

Number of extra bits to consider when encoding an image. This prevents coding overflow. Possible values are 0 - 7. The default is 2.

nDerived_Base_Mantissa

The base mantissa used for derived quantization.

nDerived_Base_Exponent

The base exponent used for derived quantization.

bUse_SOP_Marker

Flag that indicates whether to use the SOP marker. Possible values are:

 

Value

Meaning

 

TRUE

Use the SOP marker.

 

FALSE

Do not use the SOP marker. (Default)

bUse_EPH_Marker

Flag that indicates whether to use the EPH marker. Possible values are:

 

Value

Meaning

 

TRUE

Use the EPH marker.

 

FALSE

Do not use the EPH marker. (Default)

bUseROI

Flag that indicates whether to use a region of interest. Possible values are:

 

Value

Meaning

 

TRUE

Use a region of interest as specified in the uROIControl member.

 

FALSE

Do not use a region of interest. If you do not want to use a region of interest, set this to FALSE. Otherwise, there may be a significant compression and speed performance loss.

fROIWeight

Reserved for future use.

rcROI

RECT structure that contains the boundaries of the region of interest within the image.

 

uROIControl

Flag that indicates the region of interest to use. For a list of possible values refer to J2KREGIONOFINTEREST.

 

Value

Meaning

 

J2K_USE_OPTION_RECT

Use the rectangle specified in the rcROI member of the FILEJ2KOPTIONS structure to define the region of interest.

 

J2K_USE_LEAD_REGION

Use the LEAD bitmap region to define the region of interest. (Any region shape is acceptable; it will be converted internally by the filter to a rectangle.)

Comments

The resulting stream size/ compression ratio can be determined in several ways. Depending on the value set in the uCompressionControl member, the user can set the size of the target JPEG 2000 stream, the actual compression ratio to use during compression or the quality factor to use during compression. If uCompressionControl is set to J2K_COMPRESSION_RATIO, then the compression to use is based on the compression ratio in the fCompressionRatio data member. If uCompressionControl is set to J2K_COMPRESSION_TARGETSIZE, the compression to use is based on the desired target stream size in the uTargetFileSize data member. If uCompressionControl is set to J2K_COMPRESSION_QFACTOR, then compression is used based on the QFactor passed to any of the functions which can be used to replace or insert image(s) in the Pixel Data Element.

The bUse_SOP_Marker and the bUse_EPH_Marker indicate whether to include markers at the "Start of Packet" and "End of Packet Header". These markers help detect file corruption during transmission.

There are two types of quantization for lossy compression, Scalar Derived Quantization and Scalar Expounded Quantization. In Scalar Derived Quantization mantissa and exponent values for the LL Subband only are signaled. The mantissa and exponent for the other subbands are derived from the mantissa and exponent signaled for the LL subband.

In Scalar Expounded Quantization, the mantissa and exponent values for each subband are signaled.

The quantization step size for a subband is determined based on the following equation, where R = bpp for the subband:

Quantization Step = (2 (R - Exponent) ) * [1 + (Mantissa / 2048)]

The values of the uXOsiz, uYOsiz, uXTsiz, uYTsiz, uXTOsiz and uYTOsiz structure members are used to create tiles within the image. Arbitrary tile sizes are allowed. All tiles are the same size, except for the border tiles. Each tile can be compressed individually. This can decrease memory usage while the program is running, but can also generate artifacts at the edges of the tiles. Artifacts generally increase as the size of the tile decreases. By default, there is one tile that contains the entire image.