Class J2KImageWriteParamJava
ImageWriteParam for writing images in
the JPEG 2000 format.
JPEG 2000 plugin supports to losslessly or lossy compress gray-scale, RGB, and RGBA images with byte, unsigned short or short data type. It also supports losslessly compress bilevel, and 8-bit indexed. The result data is in the format of JP2 (JPEG 2000 Part 1 or baseline format).
Many encoding parameters for JPEG 2000 can be tile-component specific.
These parameters are marked as Yes in the column
TC_SPEC in the following parameter table.
They must be provided according to the pattern:
[<tile-component idx>] <param> (repeated as many time as needed),
where <tile-component idx> respect the following policy according to
the degree of priority:
| (1) t<idx> c<idx> : Tile-component specification. |
| (2) t<idx> : Tile specification. |
| (3) c<idx> : Component specification. |
| (4) <void> : Default specification. |
Where the priorities of the specifications are: (1) > (2) > (3) > (4), (">" means "overrides") <idx>: "," separates indexes, "-" separates bounds of indexes list. (for example, 0,2-4 means indexes 0,2,3 and 4).
The parameters for encoding JPEG 2000 are listed in the following table: *
| Parameter Name | Description | TC_SPEC |
|---|---|---|
| encodingRate | The bitrate in bits-per-pixel for encoding. Should be set when
lossy compression scheme is used. With the default value
Double.MAX_VALUE, a lossless compression will be done.
|
No |
| lossless | Indicates using the loseless scheme or not. It is equivalent to
use reversible quantization and 5x3 integer wavelet filters. The
default is true.
|
No |
| componentTransformation | Specifies to utilize the component transformation on some tiles. If the wavelet transform is reversible (w5x3 filter), the Reversible Component Transformation (RCT) is applied. If not reversible (w9x7 filter), the Irreversible Component Transformation (ICT) is used. | Yes, Tile_Specific |
| filters | Specifies which wavelet filters to use for the specified tile-components. JPEG 2000 part I only supports w5x3 and w9x7 filters. | Yes |
| decompositionLevel | Specifies the wavelet decomposition levels to apply to the image. If it is 0, no wavelet transform is performed, in which case the original image data will be sent to the encoder and an example is the binary data. All components and all tiles have the same number of decomposition levels. The default value is 5. | No |
| guardBits | The number of bits used for each tile-component in the quantizer to avoid overflow. It takes values in the range 0 through 7. The default value is 2. | Yes |
| quantizationStep | This parameter specifies the base normalized quantization step size for the tiles/components. It is normalized to a dynamic range of 1 in the image domain. This parameter is ignored in reversible coding. The default value is 0.0078125. | Yes |
| quantizationType | Specifies which quantization type to use for specified tiles/components. Not specified for lossless compression. By default, the quantization step size is "expounded". Supported quantization types specification are : "reversible" (no quantization), "derived" (derived quantization step size) and "expounded". | Yes |
| codeBlockSize | Specifies the maximum code-block size to use for tile-component. The maximum width and height is 1024, however the block size (i.e. width x height) must not exceed 4096. The minimum width and height is 4. The default values are (64, 64). | Yes |
| progressionType | Specifies which type of progression should be used when generating
the codestream.
The format is [<tile index>] res|layer|res-pos|pos-comp|comp-pos [res_start comp_start layer_end res_end comp_end prog] [[res_start comp_start layer_end res_end comp_end prog]...] [[<tile-component idx]...]. The value "res" generates a resolution progressive codestream with the number of layers specified by "layers" parameter. The value "layer" generates a layer progressive codestream with multiple layers. In any case, the rate-allocation algorithm optimizes for best quality in each layer. The quality measure is mean squared error (MSE) or a weighted version of it (WMSE). If no progression type is specified or imposed by other parameters, the default value is "layer". It is also possible to describe progression order changes. In this case, "res_start" is the index (from 0) of the first resolution level, "comp_start" is the index (from 0) of the first component, "layer_end" is the index (from 0) of the first layer not included, "res_end" is the index (from 0) of the first resolution level not included, "comp_end" is index (from 0) of the first component not included and "prog" is the progression type to be used for the rest of the tile/image. Several progression order changes can be specified, one after the other. |
Yes |
| packPacketHeaderInTile | Indicates that the packet headers are packed in the tiles' headers. The default is false. | No |
| packPacketHeaderInMain | Indicates that the packet headers are packed in the main header. The default is false. | No |
| packetPerTilePart | Specifies the maximum number of packets to be put into one tile-part. Zero means putting all packets in the first tile-part of each tile. | No |
| ROIs | Specifies ROIs shape and location. The component index specifies
which components contain the ROI. If this parameter is used, the
codestream is layer progressive by default unless it is overridden by
the progressionType. A rectanglar or circular ROI can be
specified in the format: [<component idx>] R <left>
<top> <width> <height> or [<component idx>] C
<center x> <center y> <radius>. An arbitrary shape
can be assigned by [<component idx>] A <PGM file>
|
Yes, component-specified |
| startLevelROI | This parameter defines the lowest resolution levels to belong to the ROI. By doing this, it is possible to avoid getting information for the ROI at an early stage of transmission. startLevelROI = 0 means the lowest resolution level belongs to the ROI, 1 means the second lowest etc. The default values, -1, deactivates this parameter. | No |
| alignROI | By specifying this parameter, the ROI mask will be limited to covering only entire code-blocks. The ROI coding can then be performed without any actual scaling of the coefficients but by instead scaling the distortion estimates. | No |
| bypass | Uses the lazy coding mode with the entropy coder. This will bypass
the MQ coder for some of the coding passes, where the distribution
is often close to uniform. Since the MQ codeword will be terminated
at least once per lazy pass, it is important to use an efficient
termination algorithm, methodForMQTermination.
true enables, and false disables it. The default value is false.
|
Yes |
| resetMQ | If this is enabled the probability estimates of the MQ coder are reset after each arithmetically coded (i.e. non-lazy) coding pass. true enables, and false disables it. The default value is false. | Yes |
| terminateOnByte | If this is enabled the codeword (raw or MQ) is terminated on a byte boundary after each coding pass. In this case it is important to use an efficient termination algorithm, "methodForMQTermination". true enables, and false disables it. The default value is false. | Yes |
| causalCXInfo | Uses vertically stripe causal context formation. If this is enabled the context formation process in one stripe is independant of the next stripe (i.e. the one below it). true enables, and false disables it. The default value is false. | Yes |
| codeSegSymbol | Inserts an error resilience segmentation symbol in the MQ codeword at the end of each bit-plane (cleanup pass). Decoders can use this information to detect and conceal errors. true enables, and false disables it. The default value is false. | Yes |
| methodForMQTermination | Specifies the algorithm used to terminate the MQ codeword. The most efficient one is "near_opt", which delivers a codeword which in almost all cases is the shortest possible. The "easy" is a simpler algorithm that delivers a codeword length that is close to the previous one (in average 1 bit longer). The "predict" is almost the same as the "easy" but it leaves error resilient information on the spare least significant bits (in average 3.5 bits), which can be used by a decoder to detect errors. The "full" algorithm performs a full flush of the MQ coder and is highly inefficient. It is important to use a good termination policy since the MQ codeword can be terminated quite often, specially if the "bypass" or "terminateOnByte" parameters are enabled (in the normal case it would be terminated once per code-block, while "terminateOnByte" is specified it will be done almost 3 times per bit-plane in each code-block). The default value is "near_opt". | Yes |
| methodForMQLengthCalc | Specifies the algorithm to use in calculating the necessary MQ length for each decoding pass. The best one is "near_opt", which performs a rather sophisticated calculation and provides the best results. The "lazy_good" and "lazy" are very simple algorithms that provide rather conservative results. "lazy_good" performs slightly better. Please use the default unless the experiments show the benefits of different length calculation algorithms. The default value is "near_opt". | Yes |
| precinctPartition | Specifies precinct partition dimensions for tiles/components. They are stored from those applied to the highest resolution to those applied to the remaining resolutions in decreasing order. If less values than the number of decomposition levels are specified, then the last two values are used for the remaining resolutions. | Yes |
| layers | Explicitly specifies the codestream layer formation parameters. The rate (double) parameter specifies the bitrate to which the first layer should be optimized. The layers (int) parameter, if present, specifies the number of extra layers that should be added for scalability. These extra layers are not optimized. Any extra rate and layers parameters add more layers, in the same way. An additional layer is always added at the end, which is optimized to the overall target bitrate of the bit stream. Any layers (optimized or not) whose target bitrate is higher that the overall target bitrate are silently ignored. The bitrates of the extra layers that are added through the layers parameter are approximately log-spaced between the other target bitrates. If several (rate, layers) constructs appear the rate parameters must appear in increasing order. The rate allocation algorithm ensures that all coded layers have a minimal reasonable size, if not these layers are silently ignored. Default: 0.015 +20 2.0 +10. | No |
| SOP | Specifies whether start of packet (SOP) markers should be used. true enables, false disables it. The default value is false. | Yes |
| EPH | Specifies whether end of packet header (EPH) markers should be used. true enables, false disables it. The default value is false. | Yes |
-
Field Summary
Fields inherited from class javax.imageio.ImageWriteParam
canOffsetTiles, canWriteCompressed, canWriteProgressive, canWriteTiles, compressionMode, compressionQuality, compressionType, compressionTypes, locale, MODE_COPY_FROM_METADATA, MODE_DEFAULT, MODE_DISABLED, MODE_EXPLICIT, preferredTileSizes, progressiveMode, tileGridXOffset, tileGridYOffset, tileHeight, tileWidth, tilingMode, tilingSetFields inherited from class javax.imageio.IIOParam
controller, defaultController, destinationOffset, destinationType, sourceBands, sourceRegion, sourceXSubsampling, sourceYSubsampling, subsamplingXOffset, subsamplingYOffset -
Constructor Summary
ConstructorsConstructorDescriptionConstructs aJ2KImageWriteParamJavaobject with default values for all parameters.J2KImageWriteParamJava(Raster raster) Constructs aJ2KImageWriteParamJavaobject with default values for all parameters.J2KImageWriteParamJava(RenderedImage imgsrc) Constructs aJ2KImageWriteParamJavaobject with default values for all parameters.J2KImageWriteParamJava(RenderedImage imgsrc, Locale locale) Constructor to set locales.J2KImageWriteParamJava(IIOImage image, ImageWriteParam param) Constructor to set locales. -
Method Summary
Modifier and TypeMethodDescriptionbooleanGetsalignROIGetsbypassGetscausalCXInfoGetscodeBlockSizeGetscodeSegSymbolGetscomponentTransformationGetsdecompositionLeveldoubleGetsencodingRategetEPH()GetsEPHGetsfiltersGetsguardBitsGetslayersbooleanGetsencodingRateGetsmethodForMQLengthCalcGetsmethodForMQTerminationintgetMinX()GetsminXintgetMinY()GetsminYintGets the number of componentsintGets the number of tilesintGetspacketPerTilePartbooleanGetspackPacketHeaderInMainbooleanGetspackPacketHeaderInTileGetsprecinctPartitionGetsprogressionTypeGetsprogressionTypeGetsquantizationStepGetsquantizationTypeGetsresetMQgetROIs()GetsROIsgetSOP()GetsSOPintGetsstartLevelGetsterminateOnBytevoidsetAlignROI(boolean align) SetsalignROIvoidSetsbypassvoidsetCausalCXInfo(String values) SetscausalCXInfovoidsetCodeBlockSize(String values) SetscodeBlockSizevoidsetCodeSegSymbol(String values) SetscodeSegSymbolvoidsetComponentTransformation(String values) SetscomponentTransformationvoidsetDecompositionLevel(String values) SetsdecompositionLevelvoidsetEncodingRate(double rate) SetsencodingRatevoidSetsEPHvoidsetFilters(String values) SetsfiltersvoidsetGuardBits(String values) SetsguardBitsvoidSets thelayersvoidsetLossless(boolean lossless) SetslosslessvoidsetMethodForMQLengthCalc(String values) SetsmethodForMQLengthCalcvoidsetMethodForMQTermination(String values) SetsmethodForMQTerminationvoidsetMinX(int minX) SetsminXvoidsetMinY(int minY) SetsminYvoidsetPacketPerTilePart(int packetPerTilePart) SetspacketPerTilePartvoidsetPackPacketHeaderInMain(boolean packPacketHeaderInMain) SetspackPacketHeaderInMainvoidsetPackPacketHeaderInTile(boolean packPacketHeaderInTile) SetspackPacketHeaderInTilevoidsetPrecinctPartition(String values) SetsprecinctPartitionvoidsetProgressionName(String values) SetsprogressionNamevoidsetProgressionType(LayersInfo lyrs, String values) SetsprogressionTypevoidsetQuantizationStep(String values) SetsquantizationStepvoidsetQuantizationType(String values) SetsquantizationTypevoidsetResetMQ(String values) SetsresetMQvoidSetsROIsvoidSetsSOPvoidsetSourceBands(int[] bands) Override the method setSourceBands in the super class.voidsetSourceSubsampling(int sx, int sy, int xOff, int yOff) Override the method setSourceSubsampling in the super class.voidsetStartLevelROI(int value) Sets thestartLevelROIvoidsetTerminateOnByte(String values) SetsterminateOnBytevoidsetTiling(int tw, int th, int xOff, int yOff) Override the method setTiling in the super class.Methods inherited from class javax.imageio.ImageWriteParam
canOffsetTiles, canWriteCompressed, canWriteProgressive, canWriteTiles, getBitRate, getCompressionMode, getCompressionQuality, getCompressionQualityDescriptions, getCompressionQualityValues, getCompressionType, getCompressionTypes, getLocale, getLocalizedCompressionTypeName, getPreferredTileSizes, getProgressiveMode, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, getTilingMode, isCompressionLossless, setCompressionMode, setCompressionQuality, setCompressionType, setProgressiveMode, setTilingMode, unsetCompression, unsetTilingMethods inherited from class javax.imageio.IIOParam
activateController, getController, getDefaultController, getDestinationOffset, getDestinationType, getSourceBands, getSourceRegion, getSourceXSubsampling, getSourceYSubsampling, getSubsamplingXOffset, getSubsamplingYOffset, hasController, setController, setDestinationOffset, setDestinationType, setSourceRegion
-
Constructor Details
-
J2KImageWriteParamJava
Constructor to set locales. -
J2KImageWriteParamJava
Constructor to set locales. -
J2KImageWriteParamJava
public J2KImageWriteParamJava()Constructs aJ2KImageWriteParamJavaobject with default values for all parameters. -
J2KImageWriteParamJava
Constructs aJ2KImageWriteParamJavaobject with default values for all parameters. -
J2KImageWriteParamJava
Constructs aJ2KImageWriteParamJavaobject with default values for all parameters.
-
-
Method Details
-
setEncodingRate
public void setEncodingRate(double rate) SetsencodingRate -
getEncodingRate
public double getEncodingRate()GetsencodingRate -
setLossless
public void setLossless(boolean lossless) Setslossless -
getLossless
public boolean getLossless()GetsencodingRate -
setPacketPerTilePart
public void setPacketPerTilePart(int packetPerTilePart) SetspacketPerTilePart -
getPacketPerTilePart
public int getPacketPerTilePart()GetspacketPerTilePart -
setPackPacketHeaderInTile
public void setPackPacketHeaderInTile(boolean packPacketHeaderInTile) SetspackPacketHeaderInTile -
getPackPacketHeaderInTile
public boolean getPackPacketHeaderInTile()GetspackPacketHeaderInTile -
setPackPacketHeaderInMain
public void setPackPacketHeaderInMain(boolean packPacketHeaderInMain) SetspackPacketHeaderInMain -
getPackPacketHeaderInMain
public boolean getPackPacketHeaderInMain()GetspackPacketHeaderInMain -
setAlignROI
public void setAlignROI(boolean align) SetsalignROI -
getAlignROI
public boolean getAlignROI()GetsalignROI -
setROIs
SetsROIs -
getROIs
GetsROIs -
setQuantizationType
SetsquantizationType -
getQuantizationType
GetsquantizationType -
setQuantizationStep
SetsquantizationStep -
getQuantizationStep
GetsquantizationStep -
setGuardBits
SetsguardBits -
getGuardBits
GetsguardBits -
setFilters
Setsfilters -
getFilters
Getsfilters -
setDecompositionLevel
SetsdecompositionLevel -
getDecompositionLevel
GetsdecompositionLevel -
setComponentTransformation
SetscomponentTransformation -
getComponentTransformation
GetscomponentTransformation -
setMethodForMQLengthCalc
SetsmethodForMQLengthCalc -
getMethodForMQLengthCalc
GetsmethodForMQLengthCalc -
setMethodForMQTermination
SetsmethodForMQTermination -
getMethodForMQTermination
GetsmethodForMQTermination -
setCodeSegSymbol
SetscodeSegSymbol -
getCodeSegSymbol
GetscodeSegSymbol -
setCausalCXInfo
SetscausalCXInfo -
getCausalCXInfo
GetscausalCXInfo -
setTerminateOnByte
SetsterminateOnByte -
getTerminateOnByte
GetsterminateOnByte -
setResetMQ
SetsresetMQ -
getResetMQ
GetsresetMQ -
setBypass
Setsbypass -
getBypass
Getsbypass -
setCodeBlockSize
SetscodeBlockSize -
getCodeBlockSize
GetscodeBlockSize -
setPrecinctPartition
SetsprecinctPartition -
getPrecinctPartition
GetsprecinctPartition -
setSOP
SetsSOP -
getSOP
GetsSOP -
setEPH
SetsEPH -
getEPH
GetsEPH -
setProgressionName
SetsprogressionName -
getProgressionName
GetsprogressionType -
setProgressionType
SetsprogressionType -
getProgressionType
GetsprogressionType -
setStartLevelROI
public void setStartLevelROI(int value) Sets thestartLevelROI -
getStartLevelROI
public int getStartLevelROI()GetsstartLevel -
setLayers
Sets thelayers -
getLayers
Getslayers -
setMinX
public void setMinX(int minX) SetsminX -
getMinX
public int getMinX()GetsminX -
setMinY
public void setMinY(int minY) SetsminY -
getMinY
public int getMinY()GetsminY -
getNumTiles
public int getNumTiles()Gets the number of tiles -
getNumComponents
public int getNumComponents()Gets the number of components -
setSourceBands
public void setSourceBands(int[] bands) Override the method setSourceBands in the super class. This method should be called before any tile-specific parameter setting method to be called.- Overrides:
setSourceBandsin classIIOParam
-
setTiling
public void setTiling(int tw, int th, int xOff, int yOff) Override the method setTiling in the super class. This method should be called before any tile-specific parameter setting method to be called.- Overrides:
setTilingin classImageWriteParam
-
setSourceSubsampling
public void setSourceSubsampling(int sx, int sy, int xOff, int yOff) Override the method setSourceSubsampling in the super class. This method should be called before any tile-specific parameter setting method to be called.- Overrides:
setSourceSubsamplingin classIIOParam
-