jj2000.j2k.wavelet.synthesis
Class InvWTFull

java.lang.Object
  |
  +--jj2000.j2k.wavelet.synthesis.InvWTAdapter
        |
        +--jj2000.j2k.wavelet.synthesis.InverseWT
              |
              +--jj2000.j2k.wavelet.synthesis.InvWTFull
All Implemented Interfaces:
BlkImgDataSrc, ImgData, InvWT, WaveletTransform

public class InvWTFull
extends InverseWT

This class implements the InverseWT with the full-page approach for int and float data.

The image can be reconstructed at different (image) resolution levels indexed from the lowest resolution available for each tile-component. This is controlled by the setImgResLevel() method.

Note: Image resolution level indexes may differ from tile-component resolution index. They are indeed indexed starting from the lowest number of decomposition levels of each component of each tile.

Example: For an image (1 tile) with 2 components (component 0 having 2 decomposition levels and component 1 having 3 decomposition levels), the first (tile-) component has 3 resolution levels and the second one has 4 resolution levels, whereas the image has only 3 resolution levels available.

This implementation does not support progressive data: Data is considered to be non-progressive (i.e. "final" data) and the 'progressive' attribute of the 'DataBlk' class is always set to false, see the 'DataBlk' class.

See Also:
DataBlk

Field Summary
private  int cblkToDecode
          The total number of code-blocks to decode
private  int dtype
          Current data type
private  int nDecCblk
          The number of already decoded code-blocks
private  int[] ndl
          Number of decomposition levels in each component
private  ProgressWatch pw
          Reference to the ProgressWatch instance if any
private  DataBlk[] reconstructedComps
          Block storing the reconstructed image for each component
private  boolean[][] reversible
          The reversible flag for each component in each tile.
private  CBlkWTDataSrcDec src
          the code-block buffer's source i.e.
 
Fields inherited from class jj2000.j2k.wavelet.synthesis.InvWTAdapter
decSpec, maxImgRes, mressrc, reslvl
 
Fields inherited from interface jj2000.j2k.wavelet.WaveletTransform
WT_IMPL_FULL, WT_IMPL_LINE
 
Constructor Summary
InvWTFull(CBlkWTDataSrcDec src, DecoderSpecs decSpec)
          Initializes this object with the given source of wavelet coefficients.
 
Method Summary
 DataBlk getCompData(DataBlk blk, int c)
          Returns a block of image data containing the specifed rectangular area, in the specified component, as a copy (see below).
 int getFixedPoint(int c)
          Returns the position of the fixed point in the specified component.
 int getImplementationType(int c)
          Returns the implementation type of this wavelet transform, WT_IMPL_FULL (full-page based transform).
 DataBlk getInternCompData(DataBlk blk, int c)
          Returns a block of image data containing the specifed rectangular area, in the specified component, as a reference to the internal buffer (see below).
 int getNomRangeBits(int c)
          Returns the number of bits, referred to as the "range bits", corresponding to the nominal range of the data in the specified component.
 boolean isReversible(int t, int c)
          Returns the reversibility of the wavelet transform for the specified component, in the current tile.
private  boolean isSubbandReversible(Subband subband)
          Returns the reversibility of the current subband.
 void nextTile()
          Advances to the next tile, in standard scan-line order (by rows then columns).
 void setTile(int x, int y)
          Changes the current tile, given the new indexes.
private  void wavelet2DReconstruction(DataBlk db, SubbandSyn sb, int c)
          Performs the 2D inverse wavelet transform on a subband of the image, on the specified component.
private  void waveletTreeReconstruction(DataBlk img, SubbandSyn sb, int c)
          Performs the inverse wavelet transform on the whole component.
 
Methods inherited from class jj2000.j2k.wavelet.synthesis.InverseWT
createInstance
 
Methods inherited from class jj2000.j2k.wavelet.synthesis.InvWTAdapter
getCompImgHeight, getCompImgWidth, getCompSubsX, getCompSubsY, getCompULX, getCompULY, getImgHeight, getImgULX, getImgULY, getImgWidth, getNomTileHeight, getNomTileWidth, getNumComps, getNumTiles, getNumTiles, getSynSubbandTree, getTile, getTileCompHeight, getTileCompWidth, getTileHeight, getTileIdx, getTilePartULX, getTilePartULY, getTileWidth, setImgResLevel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jj2000.j2k.image.ImgData
getCompImgHeight, getCompImgWidth, getCompSubsX, getCompSubsY, getCompULX, getCompULY, getImgHeight, getImgULX, getImgULY, getImgWidth, getNomTileHeight, getNomTileWidth, getNumComps, getNumTiles, getNumTiles, getTile, getTileCompHeight, getTileCompWidth, getTileHeight, getTileIdx, getTilePartULX, getTilePartULY, getTileWidth
 

Field Detail

pw

private ProgressWatch pw
Reference to the ProgressWatch instance if any


cblkToDecode

private int cblkToDecode
The total number of code-blocks to decode


nDecCblk

private int nDecCblk
The number of already decoded code-blocks


src

private CBlkWTDataSrcDec src
the code-block buffer's source i.e. the quantizer


dtype

private int dtype
Current data type


reconstructedComps

private DataBlk[] reconstructedComps
Block storing the reconstructed image for each component


ndl

private int[] ndl
Number of decomposition levels in each component


reversible

private boolean[][] reversible
The reversible flag for each component in each tile. The first index is the tile index, the second one is the component index. The reversibility of the components for each tile are calculated on a as needed basis.

Constructor Detail

InvWTFull

public InvWTFull(CBlkWTDataSrcDec src,
                 DecoderSpecs decSpec)
Initializes this object with the given source of wavelet coefficients. It initializes the resolution level for full resolutioin reconstruction.

Parameters:
src - from where the wavelet coefficinets should be obtained.
decSpec - The decoder specifications
Method Detail

isSubbandReversible

private boolean isSubbandReversible(Subband subband)
Returns the reversibility of the current subband. It computes iteratively the reversibility of the child subbands. For each subband it tests the reversibility of the horizontal and vertical synthesis filters used to reconstruct this subband.

Parameters:
subband - The current subband.
Returns:
true if all the filters used to reconstruct the current subband are reversible

isReversible

public boolean isReversible(int t,
                            int c)
Returns the reversibility of the wavelet transform for the specified component, in the current tile. A wavelet transform is reversible when it is suitable for lossless and lossy-to-lossless compression.

Parameters:
t - The index of the tile.
c - The index of the component.
Returns:
true is the wavelet transform is reversible, false if not.

getNomRangeBits

public int getNomRangeBits(int c)
Returns the number of bits, referred to as the "range bits", corresponding to the nominal range of the data in the specified component.

The returned value corresponds to the nominal dynamic range of the reconstructed image data, as long as the getNomRangeBits() method of the source returns a value corresponding to the nominal dynamic range of the image data and not not of the wavelet coefficients.

If this number is b then for unsigned data the nominal range is between 0 and 2^b-1, and for signed data it is between -2^(b-1) and 2^(b-1)-1.

Parameters:
c - The index of the component.
Returns:
The number of bits corresponding to the nominal range of the data.

getFixedPoint

public int getFixedPoint(int c)
Returns the position of the fixed point in the specified component. This is the position of the least significant integral (i.e. non-fractional) bit, which is equivalent to the number of fractional bits. For instance, for fixed-point values with 2 fractional bits, 2 is returned. For floating-point data this value does not apply and 0 should be returned. Position 0 is the position of the least significant bit in the data.

This default implementation assumes that the wavelet transform does not modify the fixed point. If that were the case this method should be overriden.

Parameters:
c - The index of the component.
Returns:
The position of the fixed-point, which is the same as the number of fractional bits. For floating-point data 0 is returned.

getInternCompData

public final DataBlk getInternCompData(DataBlk blk,
                                       int c)
Returns a block of image data containing the specifed rectangular area, in the specified component, as a reference to the internal buffer (see below). The rectangular area is specified by the coordinates and dimensions of the 'blk' object.

The area to return is specified by the 'ulx', 'uly', 'w' and 'h' members of the 'blk' argument. These members are not modified by this method.

The data returned by this method can be the data in the internal buffer of this object, if any, and thus can not be modified by the caller. The 'offset' and 'scanw' of the returned data can be arbitrary. See the 'DataBlk' class.

The returned data has its 'progressive' attribute unset (i.e. false).

Parameters:
blk - Its coordinates and dimensions specify the area to return.
c - The index of the component from which to get the data.
Returns:
The requested DataBlk
See Also:
getInternCompData(jj2000.j2k.image.DataBlk, int)

getCompData

public DataBlk getCompData(DataBlk blk,
                           int c)
Returns a block of image data containing the specifed rectangular area, in the specified component, as a copy (see below). The rectangular area is specified by the coordinates and dimensions of the 'blk' object.

The area to return is specified by the 'ulx', 'uly', 'w' and 'h' members of the 'blk' argument. These members are not modified by this method.

The data returned by this method is always a copy of the internal data of this object, if any, and 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 block's width. See the 'DataBlk' class.

If the data array in 'blk' is null, then a new one is created. If the data array is not null then it must be big enough to contain the requested area.

The returned data always has its 'progressive' attribute unset (i.e false)

Parameters:
blk - Its coordinates and dimensions specify the area to return. If it contains a non-null data array, then it must be large enough. If it contains a null data array a new one is created. The fields in this object are modified to return the data.
c - The index of the component from which to get the data.
Returns:
The requested DataBlk
See Also:
getCompData(jj2000.j2k.image.DataBlk, int)

wavelet2DReconstruction

private void wavelet2DReconstruction(DataBlk db,
                                     SubbandSyn sb,
                                     int c)
Performs the 2D inverse wavelet transform on a subband of the image, on the specified component. This method will successively perform 1D filtering steps on all columns and then all lines of the subband.

Parameters:
db - the buffer for the image/wavelet data.
sb - The subband to reconstruct.
c - The index of the component to reconstruct

waveletTreeReconstruction

private void waveletTreeReconstruction(DataBlk img,
                                       SubbandSyn sb,
                                       int c)
Performs the inverse wavelet transform on the whole component. It iteratively reconstructs the subbands from leaves up to the root node. This method is recursive, the first call to it the 'sb' must be the root of the subband tree. The method will then process the entire subband tree by calling itslef recursively.

Parameters:
img - The buffer for the image/wavelet data.
sb - The subband to reconstruct.
c - The index of the component to reconstruct

getImplementationType

public int getImplementationType(int c)
Returns the implementation type of this wavelet transform, WT_IMPL_FULL (full-page based transform). All components return the same.

Parameters:
c - The index of the component.
Returns:
WT_IMPL_FULL
See Also:
WaveletTransform.WT_IMPL_FULL

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 InvWTAdapter
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 InvWTAdapter