jj2000.j2k.image
Interface ImgData

All Known Subinterfaces:
BlkImgDataSrc, CBlkQuantDataSrcEnc, CBlkWTDataSrc, CodedCBlkDataSrcEnc, ForwWT, ForwWTDataProps, InvWT, WaveletTransform
All Known Implementing Classes:
ImgDataAdapter

public interface ImgData

This interface defines methods to access image attributes (width, height, number of components, etc.). The image can be tiled or not (i.e. if the image is not tiled then there is only 1 tile). It should be implemented by all classes that provide image data, such as image file readers, color transforms, wavelet transforms, etc. This interface, however, does not define methods to transfer image data (i.e. pixel data), that is defined by other interfaces, such as 'BlkImgDataSrc'.

The image itself is considered to lie on top of a canvas, and thus its top-left corner can be positioned at a coordinate other than (0,0). This canvas is partitioned into tiles (1 tile if there are no tiles). The origin for the partitioning into tiles might be different from the image origin. Since the tiles are a partition of the canvas, and not of the image itself, it is worth noting that some tiles (at the top, bottom, left or right) can partially lie outside of the image data. We call "active tile" the part of a tile that contains actual image data.

An image might be composed of several components (numbered from 0 to N-1), where each component can have a different resolution. We therefore define a reference grid, on which all components are layed down. Each component has an horizontal and a vertical subsampling factor, which determines the ratio of the grid's horizontal and vertical dimensions to the component's horizontal and vertical dimensions, respectively. Therefore if 'W' and 'H' are the width and height of the reference grid, 'Rx' and 'Ry' the horizontal and vertical subsampling factors, respectively, and 'ax' and 'ay' are the horizontal and vertical coordinates of the top-left corner of the reference grid with respect to the canvas origin, the width of the component is 'ceil((W+ax)/Rx)-ceil(ax/Rx)' and its height is 'ceil((H+ay)/Ry)-ceil(ay/Ry)'. Note that this formulae is not directly applicable to the tile sizes. In general, a coordinate in the reference grid is mapped to a component coordinate as 'x_c = ceil(x/Rx)' and 'y_c = ceil(y/Ry)', where '(x_c,y_c)' are the component coordinates, '(x,y)' the reference grid coordinates, both in the canvas system, and 'Rx' and 'Ry' the horizontal and vertical subsampling factors, respectively.

The reference grid dimensions are commonly referred to as "image" width and height, in contrast to component width and height. The 'getCompSubsX()' and 'getCompSubsY()' methods return the componet's subsampling factors.

The image origin '(ax,ay)' is returned by the 'getImgULX()' and 'getImgULY()' methods.

There is always one current tile. All data, coordinates and dimensions, always refer to the current active tile, unless otherwise specified. The current tile may be changed with the 'nextTile()' or 'setTile()' methods.

The coordinates (i.e. indexes) of the top-left tile are (0,0), for the other tiles the coordinates increase by one for each new tile (e.g., tile (1,2) is the second tile in the horizontal direction and the third tile in the vertical direction).

The coordinates of the top-left corner of each tile (and not of the active tile), with respect to the canvas component coordinates, is returned by the 'getTileOff()' method (these are component coordinates, not reference grid coordinates). For the top-left tile (i.e. tile (0,0)) this is the coordinates of the partitioning reference, in component coordinates. The coordinates of the top-left corner of the active tile, with respect to the tile, is returned by the 'getULX()' and 'getULY()' methods. All other coordinates, unless otherwise specified, are defined with respect to the active tile top-left corner (e.g., (0,0) is always the top-left corner of the current active tile) and are component coordinates (not reference grid coordinates).

As mentoned before the origin of tile partitioning might not be the image origin, nor the canvas one. The origin of the tile partition is a point with coordinates '(Px,Py)' in the canvas system, in the reference grid coordinates, where 'Px<=ax' and 'Py<=ay', where '(ax,ay)' is the image origin in tha canvas system, in the reference grid coordinates. The '(Px,Py)' point is the upper-left corner of the tile '(0,0)' in the canvas coordinate system, in the reference grid, which is not what the 'getTileOff()' method returns (this method returns the coordinates of the same point but in component coordinates).

Note that all other partitions (e.g., code-blocks) are done with respect a special origin, different from the above ones, which is not specified in the 'ImgData' interface.

See Also:
BlkImgDataSrc

Method Summary
 int getCompHeight(int n)
          Returns the height in pixels of the specified component in the current tile.
 int getCompImgHeight(int n)
          Returns the height in pixels of the specified component in the overall image.
 int getCompImgWidth(int n)
          Returns the width in pixels of the specified component in the overall image.
 int getCompSubsX(int n)
          Returns the component subsampling factor in the horizontal direction, for the specified component.
 int getCompSubsY(int n)
          Returns the component subsampling factor in the vertical direction, for the specified component.
 int getCompWidth(int n)
          Returns the width in pixels of the specified component in the current tile.
 int getHeight()
          Returns the overall height of the current tile in pixels.
 int getImgHeight()
          Returns the overall height of the image in pixels.
 int getImgULX()
          Returns the horizontal coordinate of the image origin, the top-left corner, in the canvas system, on the reference grid.
 int getImgULY()
          Returns the vertical coordinate of the image origin, the top-left corner, in the canvas system, on the reference grid.
 int getImgWidth()
          Returns the overall width of the image in pixels.
 int getNomRangeBits(int n)
          Returns the number of bits, referred to as the "range bits", corresponding to the nominal range of the image data in the specified component.
 int getNumComps()
          Returns the number of components in the image.
 int getNumTiles()
          Returns the total number of tiles in the image.
 Coord getNumTiles(Coord co)
          Returns the number of tiles in the horizontal and vertical directions.
 Coord getTile(Coord co)
          Returns the indixes of the current tile.
 int getTileIdx()
          Returns the index of the current tile, relative to a standard scan-line order.
 Coord getTileOff(Coord co, int n)
          Returns the horizontal and vertical offset of the upper-left corner of the current tile, in the specified component, relative to the canvas origin, in the component coordinates (not in the reference grid coordinates).
 int getULX(int n)
          Returns the horizontal coordinate of the upper-left corner of the active tile, with respect to the canvas origin, in the component coordinates, for the specified component.
 int getULY(int n)
          Returns the vertical coordinate of the upper-left corner of the active tile, with respect to the canvas origin, in the component coordinates, for the specified component.
 int getWidth()
          Returns the overall width of the current tile in pixels.
 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 indices.
 

Method Detail

getWidth

public int getWidth()
Returns the overall width of the current tile in pixels. This is the tile's width without accounting for any component subsampling. This is also referred as the reference grid width in the current tile.
Returns:
The total current tile's width in pixels.

getHeight

public int getHeight()
Returns the overall height of the current tile in pixels. This is the tile's height without accounting for any component subsampling. This is also referred as the reference grid height in the current tile.
Returns:
The total current tile's height in pixels.

getImgWidth

public int getImgWidth()
Returns the overall width of the image in pixels. This is the image's width without accounting for any component subsampling or tiling.
Returns:
The total image's width in pixels.

getImgHeight

public int getImgHeight()
Returns the overall height of the image in pixels. This is the image's height without accounting for any component subsampling or tiling.
Returns:
The total image's height in pixels.

getNumComps

public int getNumComps()
Returns the number of components in the image.
Returns:
The number of components in the image.

getCompSubsX

public int getCompSubsX(int n)
Returns the component subsampling factor in the horizontal direction, for the specified component. This is, approximately, the ratio of dimensions between the reference grid and the component itself, see the 'ImgData' interface desription for details.
Parameters:
n - The index of the component (between 0 and N-1)
Returns:
The horizontal subsampling factor of component 'n'
See Also:
ImgData

getCompSubsY

public int getCompSubsY(int n)
Returns the component subsampling factor in the vertical direction, for the specified component. This is, approximately, the ratio of dimensions between the reference grid and the component itself, see the 'ImgData' interface desription for details.
Parameters:
n - The index of the component (between 0 and N-1)
Returns:
The vertical subsampling factor of component 'n'
See Also:
ImgData

getCompWidth

public int getCompWidth(int n)
Returns the width in pixels of the specified component in the current tile.
Parameters:
n - The index of the component, from 0 to N-1.
Returns:
The width in pixels of component n in the current tile.

getCompHeight

public int getCompHeight(int n)
Returns the height in pixels of the specified component in the current tile.
Parameters:
n - The index of the component, from 0 to N-1.
Returns:
The height in pixels of component n in the current tile.

getCompImgWidth

public int getCompImgWidth(int n)
Returns the width in pixels of the specified component in the overall image.
Parameters:
n - The index of the component, from 0 to N-1.
Returns:
The width in pixels of component n in the overall image.

getCompImgHeight

public int getCompImgHeight(int n)
Returns the height in pixels of the specified component in the overall image.
Parameters:
n - The index of the component, from 0 to N-1.
Returns:
The height in pixels of component n in the overall image.

getNomRangeBits

public int getNomRangeBits(int n)
Returns the number of bits, referred to as the "range bits", corresponding to the nominal range of the image data in the specified component. If this number is n 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. In the case of transformed data which is not in the image domain (e.g., wavelet coefficients), this method returns the "range bits" of the image data that generated the coefficients.
Parameters:
n - The index of the component.
Returns:
The number of bits corresponding to the nominal range of the image data (in the image domain).

setTile

public void setTile(int x,
                    int y)
Changes the current tile, given the new indices. An IllegalArgumentException is thrown if the coordinates do not correspond to a valid tile.
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).

getTile

public Coord getTile(Coord co)
Returns the indixes of the current tile. These are the horizontal and vertical indexes of the current tile.
Parameters:
co - If not null this object is used to return the information. If null a new one is created and returned.
Returns:
The current tile's indices (vertical and horizontal indexes).

getTileIdx

public int getTileIdx()
Returns the index of the current tile, relative to a standard scan-line order.
Returns:
The current tile's index (starts at 0).

getTileOff

public Coord getTileOff(Coord co,
                        int n)
Returns the horizontal and vertical offset of the upper-left corner of the current tile, in the specified component, relative to the canvas origin, in the component coordinates (not in the reference grid coordinates). These are the coordinates of the current tile's (not active tile) upper-left corner relative to the canvas.
Parameters:
co - If not null the object is used to return the values, if null a new one is created and returned.
n - The index of the component (between 0 and N-1)
Returns:
The horizontal and vertical offsets of the upper-left corner of the current tile, for the specified component, relative to the canvas origin, in the component coordinates.

getULX

public int getULX(int n)
Returns the horizontal coordinate of the upper-left corner of the active tile, with respect to the canvas origin, in the component coordinates, for the specified component.
Parameters:
n - The index of the component (between 0 and N-1)
Returns:
The horizontal coordinate of the upper-left corner of the active tile, with respect to the canvas origin, for component 'n', in the component coordinates.

getULY

public int getULY(int n)
Returns the vertical coordinate of the upper-left corner of the active tile, with respect to the canvas origin, in the component coordinates, for the specified component.
Parameters:
n - The index of the component (between 0 and N-1)
Returns:
The vertical coordinate of the upper-left corner of the active tile, with respect to the canvas origin, for component 'n', in the component coordinates.

getImgULX

public int getImgULX()
Returns the horizontal coordinate of the image origin, the top-left corner, in the canvas system, on the reference grid.
Returns:
The horizontal coordinate of the image origin in the canvas system, on the reference grid.

getImgULY

public int getImgULY()
Returns the vertical coordinate of the image origin, the top-left corner, in the canvas system, on the reference grid.
Returns:
The vertical coordinate of the image origin in the canvas system, on the reference grid.

getNumTiles

public Coord getNumTiles(Coord co)
Returns the number of tiles in the horizontal and vertical directions.
Parameters:
co - If not null this object is used to return the information. If null a new one is created and returned.
Returns:
The number of tiles in the horizontal (Coord.x) and vertical (Coord.y) directions.

getNumTiles

public int getNumTiles()
Returns the total number of tiles in the image.
Returns:
The total number of tiles in the image.