Class J2KImageWriteParamJava
- java.lang.Object
-
- javax.imageio.IIOParam
-
- javax.imageio.ImageWriteParam
-
- com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageWriteParamJava
-
public class J2KImageWriteParamJava extends ImageWriteParam
A subclass ofImageWriteParam
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 columnTC_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: *
JPEG 2000 Plugin Decoding Parameters 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, tilingSet
-
Fields inherited from class javax.imageio.IIOParam
controller, defaultController, destinationOffset, destinationType, sourceBands, sourceRegion, sourceXSubsampling, sourceYSubsampling, subsamplingXOffset, subsamplingYOffset
-
-
Constructor Summary
Constructors Constructor Description J2KImageWriteParamJava()
Constructs aJ2KImageWriteParamJava
object with default values for all parameters.J2KImageWriteParamJava(Raster raster)
Constructs aJ2KImageWriteParamJava
object with default values for all parameters.J2KImageWriteParamJava(RenderedImage imgsrc)
Constructs aJ2KImageWriteParamJava
object 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
getAlignROI()
GetsalignROI
StringSpec
getBypass()
Getsbypass
StringSpec
getCausalCXInfo()
GetscausalCXInfo
CBlkSizeSpec
getCodeBlockSize()
GetscodeBlockSize
StringSpec
getCodeSegSymbol()
GetscodeSegSymbol
ForwCompTransfSpec
getComponentTransformation()
GetscomponentTransformation
IntegerSpec
getDecompositionLevel()
GetsdecompositionLevel
double
getEncodingRate()
GetsencodingRate
StringSpec
getEPH()
GetsEPH
AnWTFilterSpec
getFilters()
Getsfilters
GuardBitsSpec
getGuardBits()
GetsguardBits
String
getLayers()
Getslayers
boolean
getLossless()
GetsencodingRate
StringSpec
getMethodForMQLengthCalc()
GetsmethodForMQLengthCalc
StringSpec
getMethodForMQTermination()
GetsmethodForMQTermination
int
getMinX()
GetsminX
int
getMinY()
GetsminY
int
getNumComponents()
Gets the number of componentsint
getNumTiles()
Gets the number of tilesint
getPacketPerTilePart()
GetspacketPerTilePart
boolean
getPackPacketHeaderInMain()
GetspackPacketHeaderInMain
boolean
getPackPacketHeaderInTile()
GetspackPacketHeaderInTile
PrecinctSizeSpec
getPrecinctPartition()
GetsprecinctPartition
String
getProgressionName()
GetsprogressionType
ProgressionSpec
getProgressionType()
GetsprogressionType
QuantStepSizeSpec
getQuantizationStep()
GetsquantizationStep
QuantTypeSpec
getQuantizationType()
GetsquantizationType
StringSpec
getResetMQ()
GetsresetMQ
MaxShiftSpec
getROIs()
GetsROIs
StringSpec
getSOP()
GetsSOP
int
getStartLevelROI()
GetsstartLevel
StringSpec
getTerminateOnByte()
GetsterminateOnByte
void
setAlignROI(boolean align)
SetsalignROI
void
setBypass(String values)
Setsbypass
void
setCausalCXInfo(String values)
SetscausalCXInfo
void
setCodeBlockSize(String values)
SetscodeBlockSize
void
setCodeSegSymbol(String values)
SetscodeSegSymbol
void
setComponentTransformation(String values)
SetscomponentTransformation
void
setDecompositionLevel(String values)
SetsdecompositionLevel
void
setEncodingRate(double rate)
SetsencodingRate
void
setEPH(String values)
SetsEPH
void
setFilters(String values)
Setsfilters
void
setGuardBits(String values)
SetsguardBits
void
setLayers(String value)
Sets thelayers
void
setLossless(boolean lossless)
Setslossless
void
setMethodForMQLengthCalc(String values)
SetsmethodForMQLengthCalc
void
setMethodForMQTermination(String values)
SetsmethodForMQTermination
void
setMinX(int minX)
SetsminX
void
setMinY(int minY)
SetsminY
void
setPacketPerTilePart(int packetPerTilePart)
SetspacketPerTilePart
void
setPackPacketHeaderInMain(boolean packPacketHeaderInMain)
SetspackPacketHeaderInMain
void
setPackPacketHeaderInTile(boolean packPacketHeaderInTile)
SetspackPacketHeaderInTile
void
setPrecinctPartition(String values)
SetsprecinctPartition
void
setProgressionName(String values)
SetsprogressionName
void
setProgressionType(LayersInfo lyrs, String values)
SetsprogressionType
void
setQuantizationStep(String values)
SetsquantizationStep
void
setQuantizationType(String values)
SetsquantizationType
void
setResetMQ(String values)
SetsresetMQ
void
setROIs(String values)
SetsROIs
void
setSOP(String values)
SetsSOP
void
setSourceBands(int[] bands)
Override the method setSourceBands in the super class.void
setSourceSubsampling(int sx, int sy, int xOff, int yOff)
Override the method setSourceSubsampling in the super class.void
setStartLevelROI(int value)
Sets thestartLevelROI
void
setTerminateOnByte(String values)
SetsterminateOnByte
void
setTiling(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, unsetTiling
-
Methods inherited from class javax.imageio.IIOParam
activateController, getController, getDefaultController, getDestinationOffset, getDestinationType, getSourceBands, getSourceRegion, getSourceXSubsampling, getSourceYSubsampling, getSubsamplingXOffset, getSubsamplingYOffset, hasController, setController, setDestinationOffset, setDestinationType, setSourceRegion
-
-
-
-
Constructor Detail
-
J2KImageWriteParamJava
public J2KImageWriteParamJava(RenderedImage imgsrc, Locale locale)
Constructor to set locales.
-
J2KImageWriteParamJava
public J2KImageWriteParamJava(IIOImage image, ImageWriteParam param)
Constructor to set locales.
-
J2KImageWriteParamJava
public J2KImageWriteParamJava()
Constructs aJ2KImageWriteParamJava
object with default values for all parameters.
-
J2KImageWriteParamJava
public J2KImageWriteParamJava(RenderedImage imgsrc)
Constructs aJ2KImageWriteParamJava
object with default values for all parameters.
-
J2KImageWriteParamJava
public J2KImageWriteParamJava(Raster raster)
Constructs aJ2KImageWriteParamJava
object with default values for all parameters.
-
-
Method Detail
-
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
public void setROIs(String values)
SetsROIs
-
getROIs
public MaxShiftSpec getROIs()
GetsROIs
-
setQuantizationType
public void setQuantizationType(String values)
SetsquantizationType
-
getQuantizationType
public QuantTypeSpec getQuantizationType()
GetsquantizationType
-
setQuantizationStep
public void setQuantizationStep(String values)
SetsquantizationStep
-
getQuantizationStep
public QuantStepSizeSpec getQuantizationStep()
GetsquantizationStep
-
setGuardBits
public void setGuardBits(String values)
SetsguardBits
-
getGuardBits
public GuardBitsSpec getGuardBits()
GetsguardBits
-
setFilters
public void setFilters(String values)
Setsfilters
-
getFilters
public AnWTFilterSpec getFilters()
Getsfilters
-
setDecompositionLevel
public void setDecompositionLevel(String values)
SetsdecompositionLevel
-
getDecompositionLevel
public IntegerSpec getDecompositionLevel()
GetsdecompositionLevel
-
setComponentTransformation
public void setComponentTransformation(String values)
SetscomponentTransformation
-
getComponentTransformation
public ForwCompTransfSpec getComponentTransformation()
GetscomponentTransformation
-
setMethodForMQLengthCalc
public void setMethodForMQLengthCalc(String values)
SetsmethodForMQLengthCalc
-
getMethodForMQLengthCalc
public StringSpec getMethodForMQLengthCalc()
GetsmethodForMQLengthCalc
-
setMethodForMQTermination
public void setMethodForMQTermination(String values)
SetsmethodForMQTermination
-
getMethodForMQTermination
public StringSpec getMethodForMQTermination()
GetsmethodForMQTermination
-
setCodeSegSymbol
public void setCodeSegSymbol(String values)
SetscodeSegSymbol
-
getCodeSegSymbol
public StringSpec getCodeSegSymbol()
GetscodeSegSymbol
-
setCausalCXInfo
public void setCausalCXInfo(String values)
SetscausalCXInfo
-
getCausalCXInfo
public StringSpec getCausalCXInfo()
GetscausalCXInfo
-
setTerminateOnByte
public void setTerminateOnByte(String values)
SetsterminateOnByte
-
getTerminateOnByte
public StringSpec getTerminateOnByte()
GetsterminateOnByte
-
setResetMQ
public void setResetMQ(String values)
SetsresetMQ
-
getResetMQ
public StringSpec getResetMQ()
GetsresetMQ
-
setBypass
public void setBypass(String values)
Setsbypass
-
getBypass
public StringSpec getBypass()
Getsbypass
-
setCodeBlockSize
public void setCodeBlockSize(String values)
SetscodeBlockSize
-
getCodeBlockSize
public CBlkSizeSpec getCodeBlockSize()
GetscodeBlockSize
-
setPrecinctPartition
public void setPrecinctPartition(String values)
SetsprecinctPartition
-
getPrecinctPartition
public PrecinctSizeSpec getPrecinctPartition()
GetsprecinctPartition
-
setSOP
public void setSOP(String values)
SetsSOP
-
getSOP
public StringSpec getSOP()
GetsSOP
-
setEPH
public void setEPH(String values)
SetsEPH
-
getEPH
public StringSpec getEPH()
GetsEPH
-
setProgressionName
public void setProgressionName(String values)
SetsprogressionName
-
getProgressionName
public String getProgressionName()
GetsprogressionType
-
setProgressionType
public void setProgressionType(LayersInfo lyrs, String values)
SetsprogressionType
-
getProgressionType
public ProgressionSpec getProgressionType()
GetsprogressionType
-
setStartLevelROI
public void setStartLevelROI(int value)
Sets thestartLevelROI
-
getStartLevelROI
public int getStartLevelROI()
GetsstartLevel
-
setLayers
public void setLayers(String value)
Sets thelayers
-
getLayers
public String 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:
setSourceBands
in 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:
setTiling
in 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:
setSourceSubsampling
in classIIOParam
-
-