jj2000.j2k.wavelet
Class Subband

java.lang.Object
  |
  +--jj2000.j2k.wavelet.Subband
Direct Known Subclasses:
SubbandAn, SubbandSyn

public abstract class Subband
extends java.lang.Object

This abstract class represents a subband in a bidirectional tree structure that describes the subband decomposition for a wavelet transform. This class is implemented by the SubbandAn and SubbandSyn classes, which are for the analysis and synthesis sides respectively.

The element can be either a node or a leaf of the tree. If it is a node, it has 4 descendants (LL, HL, LH and HH). If it is a leaf, it has no descendant.

The tree is bidirectional. Each element in the tree structure has a "parent", which is the subband from which the element was obtained by decomposition. The only exception is the root element which, for obvious reasons, has no parent (i.e. it is null).

See Also:
SubbandAn, SubbandSyn

Field Summary
 int anGainExp
          The base 2 exponent of the analysis gain of the subband.
 int h
          The height of the subband
 boolean isNode
          True if it is a node in the tree, false if it is a leaf.
 int level
          The level in the tree to which this subband belongs, which is the number of performed wavelet decompositions to get this subband.
 int nomCBlkH
          The nominal code-block height
 int nomCBlkW
          The nominal code-block width
 Coord numCb
          The number of code-blocks (in both directions) contained in this subband.
 int orientation
          The orientation of this subband (WT_ORIENT_LL, WT_ORIENT_HL, WT_ORIENT_LH, WT_ORIENT_HH).
 int resLvl
          The resolution level to which this subband contributes.
 int sbandIdx
          The subband index within its resolution level.
 int ulcx
          The horizontal coordinate of the upper-left corner of the subband, with respect to the canvas origin, in the component's grid and subband's decomposition level.
 int ulcy
          The vertical coordinate of the upper-left corner of the subband, with respect to the canvas origin, in the component's grid and subband's decomposition level.
 int ulx
          The horizontal coordinate of the upper-left corner of the subband
 int uly
          The vertical coordinate of the upper-left corner of the subband
 int w
          The width of the subband
static int WT_ORIENT_HH
          The ID for the HH orientation
static int WT_ORIENT_HL
          The ID for the HL (horizontal high-pass) orientation
static int WT_ORIENT_LH
          The ID for the LH (vertical high-pass) orientation
static int WT_ORIENT_LL
          The ID for the LL orientation
 
Constructor Summary
Subband()
          Creates a Subband element with all the default values.
Subband(int w, int h, int ulcx, int ulcy, int lvls, WaveletFilter[] hfilters, WaveletFilter[] vfilters)
          Creates the top-level node and the entire subband tree, with the top-level dimensions, the number of decompositions, and the decomposition tree as specified.
 
Method Summary
abstract  Subband getHH()
          Returns the HH child subband of this subband.
abstract  Subband getHL()
          Returns the HL (horizontal high-pass) child subband of this subband.
abstract  WaveletFilter getHorWFilter()
          This function returns the horizontal wavelet filter relevant to this subband
abstract  Subband getLH()
          Returns the LH (vertical high-pass) child subband of this subband.
abstract  Subband getLL()
          Returns the LL child subband of this subband.
 Subband getNextResLevel()
          Returns the first leaf subband element in the next higher resolution level.
abstract  Subband getParent()
          Returns the parent of this subband.
 Subband getSubband(int x, int y)
          Returns a reference to the Subband element to which the specified point belongs.
 Subband getSubbandByIdx(int rl, int sbi)
          Returns a subband element in the tree, given its resolution level and subband index.
abstract  WaveletFilter getVerWFilter()
          This function returns the vertical wavelet filter relevant to this subband
protected  void initChilds()
          Initializes the childs of this node with the correct values.
 Subband nextSubband()
          Returns the next subband in the same resolution level, following the subband index order.
protected abstract  Subband split(WaveletFilter hfilter, WaveletFilter vfilter)
          Splits the current subband in its four subbands.
 java.lang.String toString()
          Returns subband informations in a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

WT_ORIENT_LL

public static final int WT_ORIENT_LL
The ID for the LL orientation

See Also:
Constant Field Values

WT_ORIENT_HL

public static final int WT_ORIENT_HL
The ID for the HL (horizontal high-pass) orientation

See Also:
Constant Field Values

WT_ORIENT_LH

public static final int WT_ORIENT_LH
The ID for the LH (vertical high-pass) orientation

See Also:
Constant Field Values

WT_ORIENT_HH

public static final int WT_ORIENT_HH
The ID for the HH orientation

See Also:
Constant Field Values

isNode

public boolean isNode
True if it is a node in the tree, false if it is a leaf.


orientation

public int orientation
The orientation of this subband (WT_ORIENT_LL, WT_ORIENT_HL, WT_ORIENT_LH, WT_ORIENT_HH).


level

public int level
The level in the tree to which this subband belongs, which is the number of performed wavelet decompositions to get this subband. It is 0 for the top-level (i.e. root) node.


resLvl

public int resLvl
The resolution level to which this subband contributes. 0 is the smallest resolution level (the one with the lowest frequency LL subband).


numCb

public Coord numCb
The number of code-blocks (in both directions) contained in this subband.


anGainExp

public int anGainExp
The base 2 exponent of the analysis gain of the subband. The analysis gain of a subband is defined as the gain of the previous subband (i.e. the one from which this one was obtained) multiplied by the line gain and by the column gain. The line (column) gain is the gain of the line (column) filter that was used to obtain it, which is the DC gain for a low-pass filter and the Nyquist gain for a high-pass filter. It is 0 by default.

Using the base 2 exponent of the value contrains the possible gains to powers of 2. However this is perfectly compatible to the filter normalization policy assumed here. See the split() method for more details.

See Also:
split(jj2000.j2k.wavelet.WaveletFilter, jj2000.j2k.wavelet.WaveletFilter)

sbandIdx

public int sbandIdx
The subband index within its resolution level. This value uniquely identifies a subband within a resolution level and a decomposition level within it. Note that only leaf elements represent "real" subbands, while node elements represent only intermediate stages.

It is defined recursively. The root node gets a value of 0. For a given node, with a subband index 'b', its LL descendant gets 4*b, its HL descendant 4*b+1, its LH descendant 4*b+2, and its HH descendant 4*b+3, for their subband indexes.


ulcx

public int ulcx
The horizontal coordinate of the upper-left corner of the subband, with respect to the canvas origin, in the component's grid and subband's decomposition level. This is the real horizontal index of the first column of this subband. If even the horizontal decomposition of this subband should be done with the low-pass-first convention. If odd it should be done with the high-pass-first convention.


ulcy

public int ulcy
The vertical coordinate of the upper-left corner of the subband, with respect to the canvas origin, in the component's grid and subband's decomposition level. This is the real vertical index of the first column of this subband. If even the vertical decomposition of this subband should be done with the low-pass-first convention. If odd it should be done with the high-pass-first convention.


ulx

public int ulx
The horizontal coordinate of the upper-left corner of the subband


uly

public int uly
The vertical coordinate of the upper-left corner of the subband


w

public int w
The width of the subband


h

public int h
The height of the subband


nomCBlkW

public int nomCBlkW
The nominal code-block width


nomCBlkH

public int nomCBlkH
The nominal code-block height

Constructor Detail

Subband

public Subband()
Creates a Subband element with all the default values. The dimensions are (0,0), the upper left corner is (0,0) and the upper-left corner with respect to the canvas is (0,0) too.


Subband

public Subband(int w,
               int h,
               int ulcx,
               int ulcy,
               int lvls,
               WaveletFilter[] hfilters,
               WaveletFilter[] vfilters)
Creates the top-level node and the entire subband tree, with the top-level dimensions, the number of decompositions, and the decomposition tree as specified.

For the analysis subband gain calculation it is assumed that analysis filters are normalized with a DC gain of 1 and a Nyquist gain of 2.

This constructor does not initialize the value of the magBits member variable. This variable is normally initialized by the quantizer, on the encoder side, or the bit stream reader, on the decoder side.

Parameters:
w - The top-level width
h - The top-level height
ulcx - The horizontal coordinate of the upper-left corner with respect to the canvas origin, in the component grid.
ulcy - The vertical coordinate of the upper-left corner with respect to the canvas origin, in the component grid.
lvls - The number of levels (or LL decompositions) in the tree.
hfilters - The horizontal wavelet filters (analysis or synthesis) for each resolution level, starting at resolution level 0. If there are less elements in the array than there are resolution levels, the last element is used for the remaining resolution levels.
vfilters - The vertical wavelet filters (analysis or synthesis) for each resolution level, starting at resolution level 0. If there are less elements in the array than there are resolution levels, the last element is used for the remaining resolution levels.
See Also:
WaveletTransform
Method Detail

getParent

public abstract Subband getParent()
Returns the parent of this subband. The parent of a subband is the subband from which this one was obtained by decomposition. The root element has no parent subband (null).

Returns:
The parent subband, or null for the root one.

getLL

public abstract Subband getLL()
Returns the LL child subband of this subband.

Returns:
The LL child subband, or null if there are no childs.

getHL

public abstract Subband getHL()
Returns the HL (horizontal high-pass) child subband of this subband.

Returns:
The HL child subband, or null if there are no childs.

getLH

public abstract Subband getLH()
Returns the LH (vertical high-pass) child subband of this subband.

Returns:
The LH child subband, or null if there are no childs.

getHH

public abstract Subband getHH()
Returns the HH child subband of this subband.

Returns:
The HH child subband, or null if there are no childs.

split

protected abstract Subband split(WaveletFilter hfilter,
                                 WaveletFilter vfilter)
Splits the current subband in its four subbands. This creates the four childs (LL, HL, LH and HH) and converts the leaf in a node.

Parameters:
hfilter - The horizontal wavelet filter used to decompose this subband.
vfilter - The vertical wavelet filter used to decompose this subband.
Returns:
A reference to the LL leaf (getLL()).

initChilds

protected void initChilds()
Initializes the childs of this node with the correct values. The sizes of the child subbands are calculated by taking into account the position of the subband in the canvas.

For the analysis subband gain calculation it is assumed that analysis filters are normalized with a DC gain of 1 and a Nyquist gain of 2.


nextSubband

public Subband nextSubband()
Returns the next subband in the same resolution level, following the subband index order. If already at the last subband then null is returned. If this subband is not a leaf an IllegalArgumentException is thrown.

Returns:
The next subband in the same resolution level, following the subband index order, or null if already at last subband.

getNextResLevel

public Subband getNextResLevel()
Returns the first leaf subband element in the next higher resolution level.

Returns:
The first leaf element in the next higher resolution level, or null if there is no higher resolution level.

getSubbandByIdx

public Subband getSubbandByIdx(int rl,
                               int sbi)
Returns a subband element in the tree, given its resolution level and subband index. This method searches through the tree.

Parameters:
rl - The resolution level.
sbi - The subband index, within the resolution level.

getSubband

public Subband getSubband(int x,
                          int y)
Returns a reference to the Subband element to which the specified point belongs. The specified point must be inside this (i.e. the one defined by this object) subband. This method searches through the tree.

Parameters:
x - horizontal coordinate of the specified point.
y - horizontal coordinate of the specified point.

toString

public java.lang.String toString()
Returns subband informations in a string.

Overrides:
toString in class java.lang.Object
Returns:
Subband informations

getHorWFilter

public abstract WaveletFilter getHorWFilter()
This function returns the horizontal wavelet filter relevant to this subband

Returns:
The horizontal wavelet filter

getVerWFilter

public abstract WaveletFilter getVerWFilter()
This function returns the vertical wavelet filter relevant to this subband

Returns:
The vertical wavelet filter