colorspace
Class Resampler

java.lang.Object
  |
  +--jj2000.j2k.image.ImgDataAdapter
        |
        +--colorspace.ColorSpaceMapper
              |
              +--colorspace.Resampler
All Implemented Interfaces:
BlkImgDataSrc, ImgData

public class Resampler
extends ColorSpaceMapper

This class resamples the components of an image so that all have the same number of samples. The current implementation only handles the case of 2:1 upsampling.

See Also:
jj2000.j2k.colorspace.ColorSpace

Nested Class Summary
 
Nested classes inherited from class colorspace.ColorSpaceMapper
ColorSpaceMapper.ComputedComponents
 
Field Summary
(package private)  int hspan
           
private  int maxCompSubsX
           
private  int maxCompSubsY
           
private  int minCompSubsX
           
private  int minCompSubsY
           
(package private)  int wspan
           
 
Fields inherited from class colorspace.ColorSpaceMapper
computed, csMap, dataFloat, dataInt, eol, fixedPtBitsArray, inFloat, inInt, maxValueArray, ncomps, OPT_PREFIX, pl, shiftValueArray, src, srcBlk, workDataFloat, workDataInt, workFloat, workInt
 
Fields inherited from class jj2000.j2k.image.ImgDataAdapter
imgdatasrc, tIdx
 
Constructor Summary
protected Resampler(BlkImgDataSrc src, ColorSpace csMap)
          Ctor resamples a BlkImgDataSrc so that all components have the same number of samples.
 
Method Summary
static BlkImgDataSrc createInstance(BlkImgDataSrc src, ColorSpace csMap)
          Factory method for creating instances of this class.
 DataBlk getCompData(DataBlk outblk, int c)
          Returns, in the blk argument, a block of image data containing the specifed rectangular area, in the specified component.
 int getCompImgHeight(int c)
          Returns the height in pixels of the specified component in the overall image.
 int getCompImgWidth(int c)
          Returns the width in pixels of the specified component in the overall image.
 int getCompSubsX(int c)
          Returns the component subsampling factor in the horizontal direction, for the specified component.
 int getCompSubsY(int c)
          Returns the component subsampling factor in the vertical direction, for the specified component.
 DataBlk getInternCompData(DataBlk outblk, int c)
          Return a DataBlk containing the requested component upsampled by the scale factor applied to the particular scaling direction Returns, in the blk argument, a block of image data containing the specifed rectangular area, in the specified component.
 int getTileCompHeight(int t, int c)
          Returns the height in pixels of the specified tile-component.
 int getTileCompWidth(int t, int c)
          Returns the width in pixels of the specified tile-component..
 java.lang.String toString()
          Return an appropriate String representation of this Resampler instance.
 
Methods inherited from class colorspace.ColorSpaceMapper
copyGeometry, getFixedPoint, getParameterInfo, setInternalBuffer
 
Methods inherited from class jj2000.j2k.image.ImgDataAdapter
getCompULX, getCompULY, getImgHeight, getImgULX, getImgULY, getImgWidth, getNomRangeBits, getNomTileHeight, getNomTileWidth, getNumComps, getNumTiles, getNumTiles, getTile, getTileHeight, getTileIdx, getTilePartULX, getTilePartULY, getTileWidth, nextTile, setTile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jj2000.j2k.image.ImgData
getCompULX, getCompULY, getImgHeight, getImgULX, getImgULY, getImgWidth, getNomRangeBits, getNomTileHeight, getNomTileWidth, getNumComps, getNumTiles, getNumTiles, getTile, getTileHeight, getTileIdx, getTilePartULX, getTilePartULY, getTileWidth, nextTile, setTile
 

Field Detail

minCompSubsX

private final int minCompSubsX

minCompSubsY

private final int minCompSubsY

maxCompSubsX

private final int maxCompSubsX

maxCompSubsY

private final int maxCompSubsY

wspan

final int wspan
See Also:
Constant Field Values

hspan

final int hspan
See Also:
Constant Field Values
Constructor Detail

Resampler

protected Resampler(BlkImgDataSrc src,
                    ColorSpace csMap)
             throws ColorSpaceException
Ctor resamples a BlkImgDataSrc so that all components have the same number of samples. Note the present implementation does only two to one respampling in either direction (row, column).

Parameters:
src - -- Source of image data
Method Detail

createInstance

public static BlkImgDataSrc createInstance(BlkImgDataSrc src,
                                           ColorSpace csMap)
                                    throws ColorSpaceException
Factory method for creating instances of this class.

Parameters:
src - -- source of image data
csMap - -- provides colorspace info
Returns:
Resampler instance
ColorSpaceException

getInternCompData

public DataBlk getInternCompData(DataBlk outblk,
                                 int c)
Return a DataBlk containing the requested component upsampled by the scale factor applied to the particular scaling direction Returns, in the blk argument, a block of image data containing the specifed rectangular area, in the specified component. The data is returned, as a copy of the internal data, therefore the returned data can be modified "in place".

The rectangular area to return is specified by the 'ulx', 'uly', 'w' and 'h' members of the 'blk' argument, relative to the current tile. These members are not modified by this method. 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 is reused, and it must be large enough to contain the block's data. Otherwise an 'ArrayStoreException' or an 'IndexOutOfBoundsException' is thrown by the Java system.

The returned data has its 'progressive' attribute set to that of the input data.

Specified by:
getInternCompData in interface BlkImgDataSrc
Overrides:
getInternCompData in class ColorSpaceMapper
Parameters:
c - The index of the component from which to get the data. Only 0 and 3 are valid.
Returns:
The requested DataBlk
See Also:
getCompData(jj2000.j2k.image.DataBlk, int)

toString

public java.lang.String toString()
Return an appropriate String representation of this Resampler instance.

Overrides:
toString in class java.lang.Object

getCompData

public DataBlk getCompData(DataBlk outblk,
                           int c)
Returns, in the blk argument, a block of image data containing the specifed rectangular area, in the specified component. The data is returned, as a copy of the internal data, therefore the returned data can be modified "in place".

The rectangular area to return is specified by the 'ulx', 'uly', 'w' and 'h' members of the 'blk' argument, relative to the current tile. These members are not modified by this method. 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 is reused, and it must be large enough to contain the block's data. Otherwise an 'ArrayStoreException' or an 'IndexOutOfBoundsException' is thrown by the Java system.

The returned data has its 'progressive' attribute set to that of the input data.

Specified by:
getCompData in interface BlkImgDataSrc
Overrides:
getCompData in class ColorSpaceMapper
Parameters:
c - The index of the component from which to get the data. Only 0 and 3 are valid.
Returns:
The requested DataBlk
See Also:
getInternCompData(jj2000.j2k.image.DataBlk, int)

getCompImgHeight

public int getCompImgHeight(int c)
Returns the height in pixels of the specified component in the overall image.

Specified by:
getCompImgHeight in interface ImgData
Overrides:
getCompImgHeight in class ImgDataAdapter
Parameters:
c - The index of the component, from 0 to N-1.
Returns:
The height in pixels of component n in the overall image.

getCompImgWidth

public int getCompImgWidth(int c)
Returns the width in pixels of the specified component in the overall image.

Specified by:
getCompImgWidth in interface ImgData
Overrides:
getCompImgWidth in class ImgDataAdapter
Parameters:
c - The index of the component, from 0 to N-1.
Returns:
The width in pixels of component c in the overall image.

getCompSubsX

public int getCompSubsX(int c)
Returns the component subsampling factor in the horizontal direction, for the specified component.

Specified by:
getCompSubsX in interface ImgData
Overrides:
getCompSubsX in class ImgDataAdapter
Parameters:
c - The index of the component (between 0 and N-1)
Returns:
The horizontal subsampling factor of component 'c'
See Also:
ImgData

getCompSubsY

public int getCompSubsY(int c)
Returns the component subsampling factor in the vertical direction, for the specified component.

Specified by:
getCompSubsY in interface ImgData
Overrides:
getCompSubsY in class ImgDataAdapter
Parameters:
c - The index of the component (between 0 and N-1)
Returns:
The vertical subsampling factor of component 'c'
See Also:
ImgData

getTileCompHeight

public int getTileCompHeight(int t,
                             int c)
Returns the height in pixels of the specified tile-component.

Specified by:
getTileCompHeight in interface ImgData
Overrides:
getTileCompHeight in class ImgDataAdapter
Parameters:
t - The tile index.
c - The index of the component, from 0 to N-1.
Returns:
The height in pixels of component c in tile t.

getTileCompWidth

public int getTileCompWidth(int t,
                            int c)
Returns the width in pixels of the specified tile-component..

Specified by:
getTileCompWidth in interface ImgData
Overrides:
getTileCompWidth in class ImgDataAdapter
Parameters:
t - Tile index
c - The index of the component, from 0 to N-1.
Returns:
The width in pixels of component c in tilet.