Class J2KImageWriteParamJava


  • public class J2KImageWriteParamJava
    extends ImageWriteParam
    A subclass of 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: *

    JPEG 2000 Plugin Decoding Parameters
    Parameter Name DescriptionTC_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
    • 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 a J2KImageWriteParamJava object with default values for all parameters.
      • J2KImageWriteParamJava

        public J2KImageWriteParamJava​(RenderedImage imgsrc)
        Constructs a J2KImageWriteParamJava object with default values for all parameters.
      • J2KImageWriteParamJava

        public J2KImageWriteParamJava​(Raster raster)
        Constructs a J2KImageWriteParamJava object with default values for all parameters.
    • Method Detail

      • setEncodingRate

        public void setEncodingRate​(double rate)
        Sets encodingRate
      • getEncodingRate

        public double getEncodingRate()
        Gets encodingRate
      • setLossless

        public void setLossless​(boolean lossless)
        Sets lossless
      • getLossless

        public boolean getLossless()
        Gets encodingRate
      • setPacketPerTilePart

        public void setPacketPerTilePart​(int packetPerTilePart)
        Sets packetPerTilePart
      • getPacketPerTilePart

        public int getPacketPerTilePart()
        Gets packetPerTilePart
      • setPackPacketHeaderInTile

        public void setPackPacketHeaderInTile​(boolean packPacketHeaderInTile)
        Sets packPacketHeaderInTile
      • getPackPacketHeaderInTile

        public boolean getPackPacketHeaderInTile()
        Gets packPacketHeaderInTile
      • setPackPacketHeaderInMain

        public void setPackPacketHeaderInMain​(boolean packPacketHeaderInMain)
        Sets packPacketHeaderInMain
      • getPackPacketHeaderInMain

        public boolean getPackPacketHeaderInMain()
        Gets packPacketHeaderInMain
      • setAlignROI

        public void setAlignROI​(boolean align)
        Sets alignROI
      • getAlignROI

        public boolean getAlignROI()
        Gets alignROI
      • setROIs

        public void setROIs​(String values)
        Sets ROIs
      • setQuantizationType

        public void setQuantizationType​(String values)
        Sets quantizationType
      • getQuantizationType

        public QuantTypeSpec getQuantizationType()
        Gets quantizationType
      • setQuantizationStep

        public void setQuantizationStep​(String values)
        Sets quantizationStep
      • getQuantizationStep

        public QuantStepSizeSpec getQuantizationStep()
        Gets quantizationStep
      • setGuardBits

        public void setGuardBits​(String values)
        Sets guardBits
      • getGuardBits

        public GuardBitsSpec getGuardBits()
        Gets guardBits
      • setFilters

        public void setFilters​(String values)
        Sets filters
      • setDecompositionLevel

        public void setDecompositionLevel​(String values)
        Sets decompositionLevel
      • getDecompositionLevel

        public IntegerSpec getDecompositionLevel()
        Gets decompositionLevel
      • setComponentTransformation

        public void setComponentTransformation​(String values)
        Sets componentTransformation
      • getComponentTransformation

        public ForwCompTransfSpec getComponentTransformation()
        Gets componentTransformation
      • setMethodForMQLengthCalc

        public void setMethodForMQLengthCalc​(String values)
        Sets methodForMQLengthCalc
      • getMethodForMQLengthCalc

        public StringSpec getMethodForMQLengthCalc()
        Gets methodForMQLengthCalc
      • setMethodForMQTermination

        public void setMethodForMQTermination​(String values)
        Sets methodForMQTermination
      • getMethodForMQTermination

        public StringSpec getMethodForMQTermination()
        Gets methodForMQTermination
      • setCodeSegSymbol

        public void setCodeSegSymbol​(String values)
        Sets codeSegSymbol
      • getCodeSegSymbol

        public StringSpec getCodeSegSymbol()
        Gets codeSegSymbol
      • setCausalCXInfo

        public void setCausalCXInfo​(String values)
        Sets causalCXInfo
      • getCausalCXInfo

        public StringSpec getCausalCXInfo()
        Gets causalCXInfo
      • setTerminateOnByte

        public void setTerminateOnByte​(String values)
        Sets terminateOnByte
      • getTerminateOnByte

        public StringSpec getTerminateOnByte()
        Gets terminateOnByte
      • setResetMQ

        public void setResetMQ​(String values)
        Sets resetMQ
      • getResetMQ

        public StringSpec getResetMQ()
        Gets resetMQ
      • setBypass

        public void setBypass​(String values)
        Sets bypass
      • getBypass

        public StringSpec getBypass()
        Gets bypass
      • setCodeBlockSize

        public void setCodeBlockSize​(String values)
        Sets codeBlockSize
      • getCodeBlockSize

        public CBlkSizeSpec getCodeBlockSize()
        Gets codeBlockSize
      • setPrecinctPartition

        public void setPrecinctPartition​(String values)
        Sets precinctPartition
      • getPrecinctPartition

        public PrecinctSizeSpec getPrecinctPartition()
        Gets precinctPartition
      • setSOP

        public void setSOP​(String values)
        Sets SOP
      • setEPH

        public void setEPH​(String values)
        Sets EPH
      • setProgressionName

        public void setProgressionName​(String values)
        Sets progressionName
      • getProgressionName

        public String getProgressionName()
        Gets progressionType
      • setProgressionType

        public void setProgressionType​(LayersInfo lyrs,
                                       String values)
        Sets progressionType
      • getProgressionType

        public ProgressionSpec getProgressionType()
        Gets progressionType
      • setStartLevelROI

        public void setStartLevelROI​(int value)
        Sets the startLevelROI
      • getStartLevelROI

        public int getStartLevelROI()
        Gets startLevel
      • setLayers

        public void setLayers​(String value)
        Sets the layers
      • getLayers

        public String getLayers()
        Gets layers
      • setMinX

        public void setMinX​(int minX)
        Sets minX
      • getMinX

        public int getMinX()
        Gets minX
      • setMinY

        public void setMinY​(int minY)
        Sets minY
      • getMinY

        public int getMinY()
        Gets minY
      • 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 class IIOParam
      • 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 class ImageWriteParam
      • 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 class IIOParam