Class ROIScaler

  • All Implemented Interfaces:
    ImgData, CBlkQuantDataSrcEnc, ForwWTDataProps

    public class ROIScaler
    extends ImgDataAdapter
    implements CBlkQuantDataSrcEnc
    This class deals with the ROI functionality.

    The ROI method is the Maxshift method. The ROIScaler works by scaling the quantized wavelet coefficients that do not affect the ROI (i.e background coefficients) so that these samples get a lower significance than the ROI ones. By scaling the coefficients sufficiently, the ROI coefficients can be recognized by their amplitude alone and no ROI mask needs to be generated at the decoder side.

    The source module must be a quantizer and code-block's data is exchange with thanks to CBlkWTData instances.

    See Also:
    Quantizer, CBlkWTData
    • Field Detail

      • OPT_PREFIX

        public static final char OPT_PREFIX
        The prefix for ROI Scaler options: 'R'
        See Also:
        Constant Field Values
    • Constructor Detail

      • ROIScaler

        public ROIScaler​(Quantizer src,
                         ROIMaskGenerator mg,
                         boolean roi,
                         int sLev,
                         boolean uba,
                         J2KImageWriteParamJava wp)
        Constructor of the ROI scaler, takes a Quantizer as source of data to scale.
        Parameters:
        src - The quantizer that is the source of data.
        mg - The mask generator that will be used for all components
        roi - Flag indicating whether there are rois specified.
        sLev - The resolution levels that belong entirely to ROI
        uba - Flag indicating whether block aligning is used.
        wp - The encoder parameters for addition of roi specs
    • Method Detail

      • isReversible

        public boolean isReversible​(int t,
                                    int c)
        Since ROI scaling is always a reversible operation, it calls isReversible() method of it source (the quantizer module).
        Specified by:
        isReversible in interface ForwWTDataProps
        Parameters:
        t - The tile to test for reversibility
        c - The component to test for reversibility
        Returns:
        True if the quantized data is reversible, false if not.
      • getAnSubbandTree

        public SubbandAn getAnSubbandTree​(int t,
                                          int c)
        Returns a reference to the subband tree structure representing the subband decomposition for the specified tile-component.
        Specified by:
        getAnSubbandTree in interface ForwWTDataProps
        Parameters:
        t - The index of the tile.
        c - The index of the component.
        Returns:
        The subband tree structure, see SubbandAn.
        See Also:
        SubbandAn, Subband
      • getCbULX

        public int getCbULX()
        Returns the horizontal offset of the code-block partition. Allowable values are 0 and 1, nothing else.
        Specified by:
        getCbULX in interface ForwWTDataProps
      • getCbULY

        public int getCbULY()
        Returns the vertical offset of the code-block partition. Allowable values are 0 and 1, nothing else.
        Specified by:
        getCbULY in interface ForwWTDataProps
      • createInstance

        public static ROIScaler createInstance​(Quantizer src,
                                               J2KImageWriteParamJava wp)
        Creates a ROIScaler object. The Quantizer is the source of data to scale.

        The ROI Scaler creates a ROIMaskGenerator depending on what ROI information is in the J2KImageWriteParamJava. If only rectangular ROI are used, the fast mask generator for rectangular ROI can be used.

        Parameters:
        src - The source of data to scale
        wp - The encoder parameters for addition of roi specs
        Throws:
        IllegalArgumentException - If an error occurs while parsing the options in 'pl'
      • parseROIs

        protected static Vector parseROIs​(String roiopt,
                                          int nc,
                                          Vector roiVector)
        This function parses the values given for the ROIs with the argument -Rroi. Currently only circular and rectangular ROIs are supported.

        A rectangular ROI is indicated by a 'R' followed the coordinates for the upper left corner of the ROI and then its width and height.

        A circular ROI is indicated by a 'C' followed by the coordinates of the circle center and then the radius.

        Before the R and C values, the component that are affected by the ROI are indicated.

        Parameters:
        roiopt - The info on the ROIs
        nc - number of components
        roiVector - The vcector containing the ROI parsed from the cmd line
        Returns:
        The ROIs specified in roiopt
      • getNextCodeBlock

        public CBlkWTData getNextCodeBlock​(int n,
                                           CBlkWTData cblk)
        This function gets a datablk from the entropy coder. The sample sin the block, which consists of the quantized coefficients from the quantizer, are scaled by the values given for any ROIs specified.

        The function calls on a ROIMaskGenerator to get the mask for scaling the coefficients in the current block.

        The data returned by this method is a copy of the orignal data. Therfore it can be modified "in place" without any problems after being returned. The 'offset' of the returned data is 0, and the 'scanw' is the same as the code-block width. See the 'CBlkWTData' class.

        Specified by:
        getNextCodeBlock in interface CBlkQuantDataSrcEnc
        Parameters:
        n - The component for which to return the next code-block.
        cblk - If non-null this object will be used to return the new code-block. If null a new one will be allocated and returned. If the "data" array of the object is non-null it will be reused, if possible, to return the data.
        Returns:
        The next code-block in the current tile for component 'n', or null if all code-blocks for the current tile have been returned.
        See Also:
        CBlkWTData
      • getNextInternCodeBlock

        public CBlkWTData getNextInternCodeBlock​(int c,
                                                 CBlkWTData cblk)
        This function gets a datablk from the entropy coder. The sample sin the block, which consists of the quantized coefficients from the quantizer, are scaled by the values given for any ROIs specified.

        The function calls on a ROIMaskGenerator to get the mask for scaling the coefficients in the current block.

        Specified by:
        getNextInternCodeBlock in interface CBlkQuantDataSrcEnc
        Parameters:
        c - The component for which to return the next code-block.
        cblk - If non-null this object will be used to return the new code-block. If null a new one will be allocated and returned. If the "data" array of the object is non-null it will be reused, if possible, to return the data.
        Returns:
        The next code-block in the current tile for component 'n', or null if all code-blocks for the current tile have been returned.
        See Also:
        CBlkWTData
      • getROIMaskGenerator

        public ROIMaskGenerator getROIMaskGenerator()
        This function returns the ROI mask generator.
        Returns:
        The roi mask generator
      • getBlockAligned

        public boolean getBlockAligned()
        This function returns the blockAligned flag
        Returns:
        Flag indicating whether the ROIs were block aligned
      • useRoi

        public boolean useRoi()
        This function returns the flag indicating if any ROI functionality used
        Returns:
        Flag indicating whether there are ROIs in the image
      • getParameterInfo

        public static String[][] getParameterInfo()
        Returns the parameters that are used in this class and implementing classes. It returns a 2D String array. Each of the 1D arrays is for a different option, and they have 3 elements. The first element is the option name, the second one is the synopsis, the third one is a long description of what the parameter is and the fourth is its default value. The synopsis or description may be 'null', in which case it is assumed that there is no synopsis or description of the option, respectively. Null may be returned if no options are supported.
        Returns:
        the options name, their synopsis and their explanation, or null if no options are supported.
      • setTile

        public void setTile​(int x,
                            int y)
        Changes the current tile, given the new indexes. An IllegalArgumentException is thrown if the indexes do not correspond to a valid tile.
        Specified by:
        setTile in interface ImgData
        Overrides:
        setTile in class ImgDataAdapter
        Parameters:
        x - The horizontal index of the tile.
        y - The vertical index of the new tile.
      • nextTile

        public void nextTile()
        Advances to the next tile, in standard scan-line order (by rows then columns). An NoNextElementException is thrown if the current tile is the last one (i.e. there is no next tile).
        Specified by:
        nextTile in interface ImgData
        Overrides:
        nextTile in class ImgDataAdapter