javax.media.jai
Class InterpolationTable

java.lang.Object
  |
  +--javax.media.jai.Interpolation
        |
        +--javax.media.jai.InterpolationTable
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
InterpolationBicubic, InterpolationBicubic2

public class InterpolationTable
extends Interpolation

A subclass of Interpolation that uses tables to store the interpolation kernels. The set of subpixel positions is broken up into a fixed number of "bins" and a distinct kernel is used for each bin. The number of bins must be a power of two.

An InterpolationTable defines a separable interpolation, with a set of kernels for each dimension. The number of bins may vary between the two dimensions. Both the horizontal and vertical interpolation kernels have a "key" element. This element is positioned over the which The kernels are stored in double precision, floating- and fixed-point form. The fixed point representation has a user-specified fractional precision. It is the user's responsibility to specify an appropriate level of precision that will not cause overflow when accumulating the results of a convolution against a set of source pixels, using 32-bit integer arithmetic.

See Also:
Serialized Form

Field Summary
protected  double[] dataHd
          The horizontal coefficient data in double format.
protected  float[] dataHf
          The horizontal coefficient data in floating-point format.
protected  int[] dataHi
          The horizontal coefficient data in fixed-point format.
protected  double[] dataVd
          The vertical coefficient data in double format.
protected  float[] dataVf
          The vertical coefficient data in floating-point format.
protected  int[] dataVi
          The vertical coefficient data in fixed-point format.
protected  int precisionBits
          The number of fractional bits used to describe filter coefficients.
 
Fields inherited from class javax.media.jai.Interpolation
bottomPadding, height, INTERP_BICUBIC, INTERP_BICUBIC_2, INTERP_BILINEAR, INTERP_NEAREST, leftPadding, rightPadding, subsampleBitsH, subsampleBitsV, topPadding, width
 
Constructor Summary
InterpolationTable(int key, int width, int subsampleBits, int precisionBits, double[] data)
          Constructs an InterpolationTable with identical horizontal and vertical resampling kernels.
InterpolationTable(int key, int width, int subsampleBits, int precisionBits, float[] data)
          Constructs an InterpolationTable with identical horizontal and vertical resampling kernels.
InterpolationTable(int key, int width, int subsampleBits, int precisionBits, int[] data)
          Constructs an InterpolationTable with identical horizontal and vertical resampling kernels.
InterpolationTable(int keyX, int keyY, int width, int height, int subsampleBitsH, int subsampleBitsV, int precisionBits, double[] dataH, double[] dataV)
          Constructs an InterpolationTable with specified horizontal and vertical extents (support), number of horizontal and vertical bins, fixed-point fractional precision, and double kernel entries.
InterpolationTable(int keyX, int keyY, int width, int height, int subsampleBitsH, int subsampleBitsV, int precisionBits, float[] dataH, float[] dataV)
          Constructs an InterpolationTable with specified horizontal and vertical extents (support), number of horizontal and vertical bins, fixed-point fractional precision, and float kernel entries.
InterpolationTable(int keyX, int keyY, int width, int height, int subsampleBitsH, int subsampleBitsV, int precisionBits, int[] dataH, int[] dataV)
          Constructs an InterpolationTable with specified horizontal and vertical extents (support), number of horizontal and vertical bins, fixed-point fractional precision, and int kernel entries.
 
Method Summary
 int[] getHorizontalTableData()
          Returns the integer (fixed-point) horizontal table data.
 double[] getHorizontalTableDataDouble()
          Returns the double horizontal table data.
 float[] getHorizontalTableDataFloat()
          Returns the floating-point horizontal table data.
 int getPrecisionBits()
          Returns the number of bits of fractional precision used to store the fixed-point table entries.
 int[] getVerticalTableData()
          Returns the integer (fixed-point) vertical table data.
 double[] getVerticalTableDataDouble()
          Returns the double vertical table data.
 float[] getVerticalTableDataFloat()
          Returns the floating-point vertical table data.
 double interpolate(double s__, double s_0, double s_1, double s_2, double s0_, double s00, double s01, double s02, double s1_, double s10, double s11, double s12, double s2_, double s20, double s21, double s22, float xfrac, float yfrac)
          Performs interpolation on a 4x4 grid of double samples.
 double interpolate(double s00, double s01, double s10, double s11, float xfrac, float yfrac)
          Performs interpolation on a 2x2 grid of double samples.
 float interpolate(float s00, float s01, float s10, float s11, float xfrac, float yfrac)
          Performs interpolation on a 2x2 grid of floating-point samples.
 float interpolate(float s__, float s_0, float s_1, float s_2, float s0_, float s00, float s01, float s02, float s1_, float s10, float s11, float s12, float s2_, float s20, float s21, float s22, float xfrac, float yfrac)
          Performs interpolation on a 4x4 grid of floating-point samples.
 int interpolate(int s00, int s01, int s10, int s11, int xfrac, int yfrac)
          Performs interpolation on a 2x2 grid of integral samples.
 int interpolate(int s__, int s_0, int s_1, int s_2, int s0_, int s00, int s01, int s02, int s1_, int s10, int s11, int s12, int s2_, int s20, int s21, int s22, int xfrac, int yfrac)
          Performs interpolation on a 4x4 grid of integral samples.
 int interpolateF(int s__, int s_0, int s_1, int s_2, int s0_, int s00, int s01, int s02, int s1_, int s10, int s11, int s12, int s2_, int s20, int s21, int s22, int xfrac, int yfrac)
          Performs interpolation on a 4x4 grid of integral samples.
 double interpolateH(double[] samples, float xfrac)
          Performs horizontal interpolation on a one-dimensional array of double samples representing a row of samples.
 double interpolateH(double s_, double s0, double s1, double s2, float xfrac)
          Performs horizontal interpolation on a quadruple of double samples.
 double interpolateH(double s0, double s1, float xfrac)
          Performs horizontal interpolation on a pair of double samples.
 float interpolateH(float[] samples, float xfrac)
          Performs horizontal interpolation on a one-dimensional array of floating-point samples representing a row of samples.
 float interpolateH(float s0, float s1, float xfrac)
          Performs horizontal interpolation on a pair of floating-point samples.
 float interpolateH(float s_, float s0, float s1, float s2, float xfrac)
          Performs horizontal interpolation on a quadruple of floating-point samples.
 int interpolateH(int[] samples, int xfrac)
          Performs horizontal interpolation on a one-dimensional array of integral samples.
 int interpolateH(int s0, int s1, int xfrac)
          Performs horizontal interpolation on a pair of integral samples.
 int interpolateH(int s_, int s0, int s1, int s2, int xfrac)
          Performs horizontal interpolation on a quadruple of integral samples.
 double interpolateV(double[] samples, float yfrac)
          Performs vertical interpolation on a one-dimensional array of double samples representing a column of samples.
 double interpolateV(double s_, double s0, double s1, double s2, float yfrac)
          Performs vertical interpolation on a quadruple of double samples.
 double interpolateV(double s0, double s1, float yfrac)
          Performs vertical interpolation on a pair of double samples.
 float interpolateV(float[] samples, float yfrac)
          Performs vertical interpolation on a one-dimensional array of floating-point samples representing a column of samples.
 float interpolateV(float s0, float s1, float yfrac)
          Performs vertical interpolation on a pair of floating-point samples.
 float interpolateV(float s_, float s0, float s1, float s2, float yfrac)
          Performs vertical interpolation on a quadruple of floating-point samples.
 int interpolateV(int[] samples, int yfrac)
          Performs vertical interpolation on a one-dimensional array of integral samples.
 int interpolateV(int s0, int s1, int yfrac)
          Performs vertical interpolation on a pair of integral samples.
 int interpolateV(int s_, int s0, int s1, int s2, int yfrac)
          Performs vertical interpolation on a quadruple of integral samples.
 
Methods inherited from class javax.media.jai.Interpolation
getBottomPadding, getHeight, getInstance, getLeftPadding, getRightPadding, getSubsampleBitsH, getSubsampleBitsV, getTopPadding, getWidth, interpolate, interpolate, interpolate, isSeparable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

precisionBits

protected int precisionBits
The number of fractional bits used to describe filter coefficients.

dataHd

protected double[] dataHd
The horizontal coefficient data in double format.

dataVd

protected double[] dataVd
The vertical coefficient data in double format.

dataHf

protected float[] dataHf
The horizontal coefficient data in floating-point format.

dataVf

protected float[] dataVf
The vertical coefficient data in floating-point format.

dataHi

protected int[] dataHi
The horizontal coefficient data in fixed-point format.

dataVi

protected int[] dataVi
The vertical coefficient data in fixed-point format.
Constructor Detail

InterpolationTable

public InterpolationTable(int keyX,
                          int keyY,
                          int width,
                          int height,
                          int subsampleBitsH,
                          int subsampleBitsV,
                          int precisionBits,
                          int[] dataH,
                          int[] dataV)
Constructs an InterpolationTable with specified horizontal and vertical extents (support), number of horizontal and vertical bins, fixed-point fractional precision, and int kernel entries. The kernel data values are organized as 2subsampleBits entries each containing width ints.

dataH and dataV are required to contain width * 2subsampleBitsH and height * 2subsampleBitsV entries respectively, otherwise an IllegalArgumentException will be thrown.

If dataV is null, it is assumed to be a copy of dataH and the keyY, height, and subsampleBitsV parameters are ignored.

Parameters:
keyX - The array offset of the horizontal resampling kernel center
keyY - The array offset of the vertical resampling kernel center
width - the width of a horizontal resampling kernel.
height - the height of a vertical resampling kernel. Ignored if dataV is null.
subsampleBitsH - the log (base 2) of the number of horizontal subsample positions. Must be positive.
subsampleBitsV - the log (base 2) of the number of vertical subsample positions. Must be positive. Ignored if dataV is null.
precisionBits - the number of bits of fractional precision to be used when resampling integral sample values. Must be positive. The same value is used for both horizontal and vertical resampling.
dataH - the horizontal table entries, as an int array of 2subsampleBitsH entries each of length width. The array is cloned internally.
dataV - the vertical table entries, as an int array of 2subsampleBitsV entries each of length height, or null. The array is cloned internally. If null, the dataH table is used for vertical interpolation as well and the keyY, height, and subsampleBitsV parameters are ignored.
Throws:
IllegalArgumentException - if the size of the data arrays are incorrect.

InterpolationTable

public InterpolationTable(int key,
                          int width,
                          int subsampleBits,
                          int precisionBits,
                          int[] data)
Constructs an InterpolationTable with identical horizontal and vertical resampling kernels.
Parameters:
key - The array offset of the central sample to be used during resampling.
width - the width or height of a resampling kernel.
subsampleBits - the log (base 2) of the number of subsample positions. Must be positive.
precisionBits - the number of bits of fractional precision to be used when resampling integral sample values. Must be positive.
data - the kernel entries, as an int array of width*2subsampleBits entries

InterpolationTable

public InterpolationTable(int keyX,
                          int keyY,
                          int width,
                          int height,
                          int subsampleBitsH,
                          int subsampleBitsV,
                          int precisionBits,
                          float[] dataH,
                          float[] dataV)
Constructs an InterpolationTable with specified horizontal and vertical extents (support), number of horizontal and vertical bins, fixed-point fractional precision, and float kernel entries. The kernel data values are organized as 2subsampleBits entries each containing width floats.

dataH and dataV are required to contain width * 2subsampleBitsH and height * 2subsampleBitsV entries respectively, otherwise an IllegalArgumentException will be thrown.

If dataV is null, it is assumed to be a copy of dataH and the keyY, height, and subsampleBitsV parameters are ignored.

Parameters:
keyX - The array offset of the horizontal resampling kernel center
keyY - The array offset of the vertical resampling kernel center
width - the width of a horizontal resampling kernel.
height - the height of a vertical resampling kernel. Ignored if dataV is null.
subsampleBitsH - the log (base 2) of the number of horizontal subsample positions. Must be positive.
subsampleBitsV - the log (base 2) of the number of vertical subsample positions. Must be positive. Ignored if dataV is null.
precisionBits - the number of bits of fractional precision to be used when resampling integral sample values. The same value is used for both horizontal and vertical resampling. Must be positive.
dataH - the horizontal table entries, as a float array of 2subsampleBitsH entries each of length width.
dataV - the vertical table entries, as a float array of 2subsampleBitsV entries each of length height, or null. If null, the dataH table is used for vertical interpolation as well and the keyY, height, and subsampleBitsV parameters are ignored.
Throws:
IllegalArgumentException - if the size of the data arrays are incorrect.

InterpolationTable

public InterpolationTable(int key,
                          int width,
                          int subsampleBits,
                          int precisionBits,
                          float[] data)
Constructs an InterpolationTable with identical horizontal and vertical resampling kernels.
Parameters:
key - The number of samples to the left or above the central sample to be used during resampling.
width - the width or height of a resampling kernel.
subsampleBits - the log (base 2) of the number of subsample positions. Must be positive.
precisionBits - the number of bits of fractional precision to be used when resampling integral sample values. Must be positive.
data - the kernel entries, as a float array of width*2subsampleBits entries

InterpolationTable

public InterpolationTable(int keyX,
                          int keyY,
                          int width,
                          int height,
                          int subsampleBitsH,
                          int subsampleBitsV,
                          int precisionBits,
                          double[] dataH,
                          double[] dataV)
Constructs an InterpolationTable with specified horizontal and vertical extents (support), number of horizontal and vertical bins, fixed-point fractional precision, and double kernel entries. The kernel data values are organized as 2subsampleBits entries each containing width doubles.

dataH and dataV are required to contain width * 2subsampleBitsH and height * 2subsampleBitsV entries respectively, otherwise an IllegalArgumentException will be thrown.

If dataV is null, it is assumed to be a copy of dataH and the keyY, height, and subsampleBitsV parameters are ignored.

Parameters:
keyX - The array offset of the horizontal resampling kernel center
keyY - The array offset of the vertical resampling kernel center
width - the width of a horizontal resampling kernel.
height - the height of a vertical resampling kernel. Ignored if dataV is null.
subsampleBitsH - the log (base 2) of the number of horizontal subsample positions. Must be positive.
subsampleBitsV - the log (base 2) of the number of vertical subsample positions. Must be positive. Ignored if dataV is null.
precisionBits - the number of bits of fractional precision to be used when resampling integral sample values. The same value is used for both horizontal and vertical resampling. Must be positive.
dataH - the horizontal table entries, as a double array of 2subsampleBitsH entries each of length width.
dataV - the vertical table entries, as a double array of 2subsampleBitsV entries each of length height, or null. If null, the dataH table is used for vertical interpolation as well and the keyY, height, and subsampleBitsV parameters are ignored.

InterpolationTable

public InterpolationTable(int key,
                          int width,
                          int subsampleBits,
                          int precisionBits,
                          double[] data)
Constructs an InterpolationTable with identical horizontal and vertical resampling kernels.
Parameters:
key - The number of samples to the left or above the central sample to be used during resampling.
width - the width or height of a resampling kernel.
subsampleBits - the log (base 2) of the number of subsample positions. Must be positive.
precisionBits - the number of bits of fractional precision to be used when resampling integral sample values. Must be positive.
data - the kernel entries, as a double array of width*2subsampleBitsH entries
Method Detail

getPrecisionBits

public int getPrecisionBits()
Returns the number of bits of fractional precision used to store the fixed-point table entries.

getHorizontalTableData

public int[] getHorizontalTableData()
Returns the integer (fixed-point) horizontal table data. The output is an int array of length getWidth() * 2getSubsampleBitsH().

The following code, given an instance interp of class InterpolationTable, will perform interpolation of a set of getWidth() samples at a given fractional position (bin) xfrac between 0 and 2getSubsampleBitsH() - 1:

 int interpolateH(InterpolationTable interp, int[] samples, int xfrac) {
     int[] dataH = interp.getHorizontalTableData();
     int precisionBits = interp.getPrecisionBits();
     int round = 1 << (precisionBits - 1);
     int width = interp.getWidth();
     int offset = width*xfrac;

     int sum = 0;
     for (int i = 0; i < width; i++) {
         sum += dataH[offset + i]*samples[i];
     }
     return (sum + round) >> precisionBits;
 }
 

In practice, the values dataH, precisionBits, etc., may be extracted once and reused to interpolate multiple output pixels.

Returns:
An array of ints.

getVerticalTableData

public int[] getVerticalTableData()
Returns the integer (fixed-point) vertical table data. The output is an int array of length getHeight() * 2getSubsampleBitsV().

The following code, given an instance interp of class InterpolationTable, will perform interpolation of a set of getHeight() samples at a given fractional position (bin) yfrac between 0 and 2getSubsampleBitsV() - 1:

 int interpolateV(InterpolationTable interp, int[] samples, int yfrac) {
     int[] dataV = interp.getVerticalTableData();
     int precisionBits = interp.getPrecisionBits();
     int round = 1 << (precisionBits - 1);
     int height = interp.getHeight();
     int offset = height*yfrac;

     int sum = 0;
     for (int i = 0; i < height; i++) {
         sum += dataV[offset + i]*samples[i];
     }
     return (sum + round) >> precisionBits;
 }
 

In practice, the values dataV, precisionBits, etc., may be extracted once and reused to interpolate multiple output pixels.

Returns:
An array of ints.

getHorizontalTableDataFloat

public float[] getHorizontalTableDataFloat()
Returns the floating-point horizontal table data. The output is a float array of length getWidth() * 2getSubsampleBitsH().

The following code, given an instance interp of class InterpolationTable, will perform interpolation of a set of getWidth() floating-point samples at a given fractional position xfrac between 0.0F and 1.0F:

 float interpolateH(InterpolationTable interp,
                    float[] samples, float xfrac) {
     float[] dataH = interp.getHorizontalTableDataFloat();
     int width = interp.getWidth();
     int numSubsamplesH = 1 << getSubsampleBitsH();
     int ifrac = (int)(xfrac*numSubsamplesH);
     int offset = width*ifrac;

     float sum = 0.0F;
     for (int i = 0; i < width; i++) {
         sum += dataH[offset + i]*samples[i];
     }
     return sum;
 }
 

In practice, the values dataH, numSubsamplesH, etc., may be extracted once and reused to interpolate multiple output pixels.

Returns:
An array of floats.

getVerticalTableDataFloat

public float[] getVerticalTableDataFloat()
Returns the floating-point vertical table data. The output is a float array of length getWidth() * 2getSubsampleBitsV().

The following code, given an instance interp of class InterpolationTable, will perform interpolation of a set of getHeight() floating-point samples at a given fractional position yfrac between 0.0F and 1.0F:

 float interpolateV(InterpolationTable interp,
                    float[] samples, float yfrac) {
     float[] dataV = interp.getVerticalTableDataFloat();
     int height = interp.getHeight();
     int numSubsamplesV = 1 << getSubsampleBitsV();
     int ifrac = (int)(yfrac*numSubsamplesV);
     int offset = height*ifrac;

     float sum = 0.0F;
     for (int i = 0; i < height; i++) {
         sum += dataV[offset + i]*samples[i];
     }
     return sum;
 }
 

In practice, the values dataV, numSubsamplesV, etc., may be extracted once and reused to interpolate multiple output pixels.

Returns:
An array of floats.

getHorizontalTableDataDouble

public double[] getHorizontalTableDataDouble()
Returns the double horizontal table data. The output is a double array of length getWidth() * 2getSubsampleBitsH().

The following code, given an instance interp of class InterpolationTable, will perform interpolation of a set of getWidth() double samples at a given fractional position xfrac between 0.0F and 1.0F:

 double interpolateH(InterpolationTable interp,
                     double[] samples, float xfrac) {
     double[] dataH = interp.getHorizontalTableDataDouble();
     int width = interp.getWidth();
     int numSubsamplesH = 1 << getSubsampleBitsH();
     int ifrac = (int)(xfrac*numSubsamplesH);
     int offset = width*ifrac;

     double sum = 0.0;
     for (int i = 0; i < width; i++) {
         sum += dataH[offset + i]*samples[i];
     }
     return sum;
 }
 

In practice, the values dataH, numSubsamplesH, etc., may be extracted once and reused to interpolate multiple output pixels.

Returns:
An array of doubles.

getVerticalTableDataDouble

public double[] getVerticalTableDataDouble()
Returns the double vertical table data. The output is a double array of length getHeight() * 2getSubsampleBitsV()).

The following code, given an instance interp of class InterpolationTable, will perform interpolation of a set of getHeight() double samples at a given fractional position yfrac between 0.0F and 1.0F:

 double interpolateV(InterpolationTable interp,
                     double[] samples, float yfrac) {
     double[] dataV = interp.getVerticalTableDataDouble();
     int height = interp.getHeight();
     int numSubsamplesV = 1 << getSubsampleBitsV();
     int ifrac = (int)(yfrac*numSubsamplesV);
     int offset = height*ifrac;

     double sum = 0.0;
     for (int i = 0; i < height; i++) {
         sum += dataV[offset + i]*samples[i];
     }
     return sum;
 }
 

In practice, the values dataV, numSubsamplesV, etc., may be extracted once and reused to interpolate multiple output pixels.

Returns:
An array of doubles.

interpolateH

public int interpolateH(int[] samples,
                        int xfrac)
Performs horizontal interpolation on a one-dimensional array of integral samples. If xfrac does not lie between 0 and 2subsampleBitsH-1, an ArrayIndexOutOfBoundsException may occur, where width is the width of the horizontal resampling kernel.
Overrides:
interpolateH in class Interpolation
Parameters:
samples - an array of ints.
xfrac - the subsample position, multiplied by 2subsampleBitsH.
Returns:
the interpolated value as an int.
Throws:
ArrayIndexOutOfBoundsException - if xfrac is out of bounds.

interpolateV

public int interpolateV(int[] samples,
                        int yfrac)
Performs vertical interpolation on a one-dimensional array of integral samples. If yfrac does not lie between 0 and 2subsampleBitsV-1, an ArrayIndexOutOfBoundsException may occur, where height is the height of the vertical resampling kernel.
Overrides:
interpolateV in class Interpolation
Parameters:
samples - an array of ints.
yfrac - the Y subsample position, multiplied by 2subsampleBitsV.
Returns:
the interpolated value as an int.
Throws:
ArrayIndexOutOfBoundsException - if yfrac is out of bounds.

interpolateH

public int interpolateH(int s0,
                        int s1,
                        int xfrac)
Performs horizontal interpolation on a pair of integral samples. This method may be used instead of the array version for speed. It should only be called if width == 2. If xfrac does not lie between 0 and 2subsampleBitsH-1, an ArrayIndexOutOfBoundsException may occur, where width is the width of the horizontal resampling kernel.
Overrides:
interpolateH in class Interpolation
Parameters:
s0 - the central sample.
s1 - the sample to the right of the central sample.
xfrac - the subsample position, multiplied by 2subsampleBitsH.
Returns:
the interpolated value as an int.
Throws:
ArrayIndexOutOfBoundsException - if xfrac is out of bounds.

interpolateH

public int interpolateH(int s_,
                        int s0,
                        int s1,
                        int s2,
                        int xfrac)
Performs horizontal interpolation on a quadruple of integral samples. This method may be used instead of the array version for speed. It should only be called if width == 4 and keyX == 1. If xfrac does not lie between 0 and 2subsampleBitsH-1, an ArrayIndexOutOfBoundsException may occur, where width is the width of the horizontal resampling kernel.
Overrides:
interpolateH in class Interpolation
Parameters:
s_ - the sample to the left of the central sample.
s0 - the central sample.
s1 - the sample to the right of the central sample.
s2 - the sample to the right of s1.
xfrac - the subsample position, multiplied by 2subsampleBitsH.
Returns:
the interpolated value as an int.
Throws:
ArrayIndexOutOfBoundsException - if xfrac is out of bounds.

interpolateV

public int interpolateV(int s0,
                        int s1,
                        int yfrac)
Performs vertical interpolation on a pair of integral samples. This method may be used instead of the array version for speed. It should only be called if height == 2 and keyY == 0. If yfrac does not lie between 0 and 2subsampleBitsV-1, an ArrayIndexOutOfBoundsException may occur, where height is the height of the vertical resampling kernel.
Overrides:
interpolateV in class Interpolation
Parameters:
s0 - the central sample.
s1 - the sample below the central sample.
yfrac - the Y subsample position, multiplied by 2subsampleBitsV.
Returns:
the interpolated value as an int.
Throws:
ArrayIndexOutOfBoundsException - if yfrac is out of bounds.

interpolateV

public int interpolateV(int s_,
                        int s0,
                        int s1,
                        int s2,
                        int yfrac)
Performs vertical interpolation on a quadruple of integral samples. This method may be used instead of the array version for speed. It should only be called if height == 4 and keyY == 1. If yfrac does not lie between 0 and 2subsampleBitsV-1, an ArrayIndexOutOfBoundsException may occur, where height is the height of the vertical resampling kernel.
Overrides:
interpolateV in class Interpolation
Parameters:
s_ - the sample above the central sample.
s0 - the central sample.
s1 - the sample below the central sample.
s2 - the sample below s1.
yfrac - the Y subsample position, multiplied by 2subsampleBitsV.
Returns:
the interpolated value as an int.
Throws:
ArrayIndexOutOfBoundsException - if yfrac is out of bounds.

interpolate

public int interpolate(int s00,
                       int s01,
                       int s10,
                       int s11,
                       int xfrac,
                       int yfrac)
Performs interpolation on a 2x2 grid of integral samples. It should only be called if width == height == 2 and keyX == keyY == 0. If xfrac does not lie between 0 and 2subsampleBitsH-1, or yfrac does not lie between 0 and 2subsampleBitsV-1, an ArrayIndexOutOfBoundsException may occur, where width and height are the width and height of the horizontal and vertical resampling kernels respectively.
Overrides:
interpolate in class Interpolation
Parameters:
s00 - the central sample.
s01 - the sample to the right of the central sample.
s10 - the sample below the central sample.
s11 - the sample below and to the right of the central sample.
xfrac - the X subsample position, multiplied by 2subsampleBitsH.
yfrac - the Y subsample position, multiplied by 2subsampleBitsV.
Returns:
the interpolated value as an int.
Throws:
ArrayIndexOutOfBoundsException - if xfrac or yfrac are out of bounds.

interpolate

public int interpolate(int s__,
                       int s_0,
                       int s_1,
                       int s_2,
                       int s0_,
                       int s00,
                       int s01,
                       int s02,
                       int s1_,
                       int s10,
                       int s11,
                       int s12,
                       int s2_,
                       int s20,
                       int s21,
                       int s22,
                       int xfrac,
                       int yfrac)
Performs interpolation on a 4x4 grid of integral samples. It should only be called if width == height == 4 and keyX == keyY == 1. If xfrac does not lie between 0 and 2subsampleBitsH-1, or yfrac does not lie between 0 and 2subsampleBitsV-1, an ArrayIndexOutOfBoundsException may occur, where width and height are the the width and height of the horizontal and vertical resampling kernels respectively.
Overrides:
interpolate in class Interpolation
Parameters:
s__ - the sample above and to the left of the central sample.
s_0 - the sample above the central sample.
s_1 - the sample above and one to the right of the central sample.
s_2 - the sample above and two to the right of the central sample.
s0_ - the sample to the left of the central sample.
s00 - the central sample.
s01 - the sample to the right of the central sample.
s02 - the sample two to the right of the central sample.
s1_ - the sample below and one to the left of the central sample.
s10 - the sample below the central sample.
s11 - the sample below and one to the right of the central sample.
s12 - the sample below and two to the right of the central sample.
s2_ - the sample two below and one to the left of the central sample.
s20 - the sample two below the central sample.
s21 - the sample two below and one to the right of the central sample.
s22 - the sample two below and two to the right of the central sample.
xfrac - the X subsample position, multiplied by 2subsampleBitsH.
yfrac - the Y subsample position, multiplied by 2subsampleBitsV.
Returns:
the interpolated value as an int.
Throws:
ArrayIndexOutOfBoundsException - if xfrac or yfrac are out of bounds.

interpolateF

public int interpolateF(int s__,
                        int s_0,
                        int s_1,
                        int s_2,
                        int s0_,
                        int s00,
                        int s01,
                        int s02,
                        int s1_,
                        int s10,
                        int s11,
                        int s12,
                        int s2_,
                        int s20,
                        int s21,
                        int s22,
                        int xfrac,
                        int yfrac)
Performs interpolation on a 4x4 grid of integral samples. All internal calculations are performed in floating-point. It should only be called if width == height == 4 and keyX == keyY == 1. If xfrac does not lie between 0 and 2subsampleBitsH-1, or yfrac does not lie between 0 and 2subsampleBitsV-1, an ArrayIndexOutOfBoundsException may occur, where width and height are the width and height of horizontal and vertical resampling kernels respectively.
Parameters:
s__ - the sample above and to the left of the central sample.
s_0 - the sample above the central sample.
s_1 - the sample above and one to the right of the central sample.
s_2 - the sample above and two to the right of the central sample.
s0_ - the sample to the left of the central sample.
s00 - the central sample.
s01 - the sample to the right of the central sample.
s02 - the sample two to the right of the central sample.
s1_ - the sample below and one to the left of the central sample.
s10 - the sample below the central sample.
s11 - the sample below and one to the right of the central sample.
s12 - the sample below and two to the right of the central sample.
s2_ - the sample two below and one to the left of the central sample.
s20 - the sample two below the central sample.
s21 - the sample two below and one to the right of the central sample.
s22 - the sample two below and two to the right of the central sample.
xfrac - the X subsample position, multiplied by 2subsampleBitsH.
yfrac - the Y subsample position, multiplied by 2subsampleBitsV.
Returns:
the interpolated value as an int.
Throws:
ArrayIndexOutOfBoundsException - if xfrac or yfrac are out of bounds.

interpolateH

public float interpolateH(float[] samples,
                          float xfrac)
Performs horizontal interpolation on a one-dimensional array of floating-point samples representing a row of samples. If xfrac does not lie between the range [0.0, 1.0F), an ArrayIndexOutOfBoundsException may occur.
Overrides:
interpolateH in class Interpolation
Parameters:
samples - an array of floats.
xfrac - the X subsample position, in the range [0.0F, 1.0F).
Returns:
the interpolated value as a float.
Throws:
ArrayIndexOutOfBoundsException - if xfrac is out of bounds.

interpolateV

public float interpolateV(float[] samples,
                          float yfrac)
Performs vertical interpolation on a one-dimensional array of floating-point samples representing a column of samples. If yfrac does not lie between the range [0.0, 1.0F), an ArrayIndexOutOfBoundsException may occur.
Overrides:
interpolateV in class Interpolation
Parameters:
samples - an array of floats.
yfrac - the Y subsample position, in the range [0.0F, 1.0F).
Returns:
the interpolated value as a float.
Throws:
ArrayIndexOutOfBoundsException - if yfrac is out of bounds.

interpolateH

public float interpolateH(float s0,
                          float s1,
                          float xfrac)
Performs horizontal interpolation on a pair of floating-point samples. This method may be used instead of the array version for speed. It should only be called if width == 2. If xfrac does not lie between the range [0.0, 1.0F), an ArrayIndexOutOfBoundsException may occur.
Overrides:
interpolateH in class Interpolation
Parameters:
s0 - the central sample.
s1 - the sample to the right of the central sample.
xfrac - the X subsample position, in the range [0.0F, 1.0F).
Returns:
the interpolated value as a float.
Throws:
ArrayIndexOutOfBoundsException - if xfrac is out of bounds.

interpolateH

public float interpolateH(float s_,
                          float s0,
                          float s1,
                          float s2,
                          float xfrac)
Performs horizontal interpolation on a quadruple of floating-point samples. This method may be used instead of the array version for speed. It should only be called if width == 4 and keyX == 1. If xfrac does not lie between the range [0.0, 1.0F), an ArrayIndexOutOfBoundsException may occur.
Overrides:
interpolateH in class Interpolation
Parameters:
s_ - the sample to the left of the central sample.
s0 - the central sample.
s1 - the sample to the right of the central sample.
s2 - the sample to the right of s1.
xfrac - the X subsample position, in the range [0.0F, 1.0F).
Returns:
the interpolated value as a float.
Throws:
ArrayIndexOutOfBoundsException - if xfrac is out of bounds.

interpolateV

public float interpolateV(float s0,
                          float s1,
                          float yfrac)
Performs vertical interpolation on a pair of floating-point samples. This method may be used instead of the array version for speed. It should only be called if height == 2 and keyY == 0. If yfrac does not lie between the range [0.0, 1.0F), an ArrayIndexOutOfBoundsException may occur.
Overrides:
interpolateV in class Interpolation
Parameters:
s0 - the central sample.
s1 - the sample below the central sample.
yfrac - the Y subsample position, in the range [0.0F, 1.0F).
Returns:
the interpolated value as a float.
Throws:
ArrayIndexOutOfBoundsException - if yfrac is out of bounds.

interpolateV

public float interpolateV(float s_,
                          float s0,
                          float s1,
                          float s2,
                          float yfrac)
Performs vertical interpolation on a quadruple of floating-point samples. This method may be used instead of the array version for speed. It should only be called if height == 4 and keyY == 1. If yfrac does not lie between the range [0.0, 1.0F), an ArrayIndexOutOfBoundsException may occur.
Overrides:
interpolateV in class Interpolation
Parameters:
s_ - the sample above the central sample.
s0 - the central sample.
s1 - the sample below the central sample.
s2 - the sample below s1.
yfrac - the Y subsample position, in the range [0.0F, 1.0F).
Returns:
the interpolated value as a float.
Throws:
ArrayIndexOutOfBoundsException - if yfrac is out of bounds.

interpolate

public float interpolate(float s00,
                         float s01,
                         float s10,
                         float s11,
                         float xfrac,
                         float yfrac)
Performs interpolation on a 2x2 grid of floating-point samples. It should only be called if width == height == 2 and keyX == keyY == 0. If either xfrac or yfrac does not lie between the range [0.0, 1.0F), an ArrayIndexOutOfBoundsException may occur.
Overrides:
interpolate in class Interpolation
Parameters:
s00 - the central sample.
s01 - the sample to the right of the central sample.
s10 - the sample below the central sample.
s11 - the sample below and to the right of the central sample.
xfrac - the X subsample position, in the range [0.0F, 1.0F).
yfrac - the Y subsample position, in the range [0.0F, 1.0F).
Returns:
the interpolated value as a float.
Throws:
ArrayIndexOutOfBoundsException - if xfrac or yfrac are out of bounds.

interpolate

public float interpolate(float s__,
                         float s_0,
                         float s_1,
                         float s_2,
                         float s0_,
                         float s00,
                         float s01,
                         float s02,
                         float s1_,
                         float s10,
                         float s11,
                         float s12,
                         float s2_,
                         float s20,
                         float s21,
                         float s22,
                         float xfrac,
                         float yfrac)
Performs interpolation on a 4x4 grid of floating-point samples. It should only be called if width == height == 4 and keyX == keyY == 1. If either xfrac or yfrac does not lie between the range [0.0, 1.0F), an ArrayIndexOutOfBoundsException may occur.
Overrides:
interpolate in class Interpolation
Parameters:
s__ - the sample above and to the left of the central sample.
s_0 - the sample above the central sample.
s_1 - the sample above and one to the right of the central sample.
s_2 - the sample above and two to the right of the central sample.
s0_ - the sample to the left of the central sample.
s00 - the central sample.
s01 - the sample to the right of the central sample.
s02 - the sample two to the right of the central sample.
s1_ - the sample below and one to the left of the central sample.
s10 - the sample below the central sample.
s11 - the sample below and one to the right of the central sample.
s12 - the sample below and two to the right of the central sample.
s2_ - the sample two below and one to the left of the central sample.
s20 - the sample two below the central sample.
s21 - the sample two below and one to the right of the central sample.
s22 - the sample two below and two to the right of the central sample.
xfrac - the X subsample position, in the range [0.0F, 1.0F).
yfrac - the Y subsample position, in the range [0.0F, 1.0F).
Returns:
the interpolated value as a float.
Throws:
ArrayIndexOutOfBoundsException - if xfrac or yfrac are out of bounds.

interpolateH

public double interpolateH(double[] samples,
                           float xfrac)
Performs horizontal interpolation on a one-dimensional array of double samples representing a row of samples. If xfrac does not lie between the range [0.0, 1.0F), an ArrayIndexOutOfBoundsException may occur.
Overrides:
interpolateH in class Interpolation
Parameters:
samples - an array of doubles.
xfrac - the X subsample position, in the range [0.0F, 1.0F).
Returns:
the interpolated value as a double.
Throws:
ArrayIndexOutOfBoundsException - if xfrac is out of bounds.

interpolateV

public double interpolateV(double[] samples,
                           float yfrac)
Performs vertical interpolation on a one-dimensional array of double samples representing a column of samples. If yfrac does not lie between the range [0.0, 1.0F), an ArrayIndexOutOfBoundsException may occur.
Overrides:
interpolateV in class Interpolation
Parameters:
samples - an array of doubles.
yfrac - the Y subsample position, in the range [0.0F, 1.0F).
Returns:
the interpolated value as a double.
Throws:
ArrayIndexOutOfBoundsException - if yfrac is out of bounds.

interpolateH

public double interpolateH(double s0,
                           double s1,
                           float xfrac)
Performs horizontal interpolation on a pair of double samples. This method may be used instead of the array version for speed. It should only be called if width == 2. If xfrac does not lie between the range [0.0, 1.0F), an ArrayIndexOutOfBoundsException may occur.
Overrides:
interpolateH in class Interpolation
Parameters:
s0 - the central sample.
s1 - the sample to the right of the central sample.
xfrac - the X subsample position, in the range [0.0F, 1.0F).
Returns:
the interpolated value as a double.
Throws:
ArrayIndexOutOfBoundsException - if xfrac is out of bounds.

interpolateH

public double interpolateH(double s_,
                           double s0,
                           double s1,
                           double s2,
                           float xfrac)
Performs horizontal interpolation on a quadruple of double samples. This method may be used instead of the array version for speed. It should only be called if width == 4 and keyX == 1. If xfrac does not lie between the range [0.0, 1.0F), an ArrayIndexOutOfBoundsException may occur.
Overrides:
interpolateH in class Interpolation
Parameters:
s_ - the sample to the left of the central sample.
s0 - the central sample.
s1 - the sample to the right of the central sample.
s2 - the sample to the right of s1.
xfrac - the X subsample position, in the range [0.0F, 1.0F).
Returns:
the interpolated value as a double.
Throws:
ArrayIndexOutOfBoundsException - if xfrac is out of bounds.

interpolateV

public double interpolateV(double s0,
                           double s1,
                           float yfrac)
Performs vertical interpolation on a pair of double samples. This method may be used instead of the array version for speed. It should only be called if height == 2 and keyY == 0. If yfrac does not lie between the range [0.0, 1.0F), an ArrayIndexOutOfBoundsException may occur.
Overrides:
interpolateV in class Interpolation
Parameters:
s0 - the central sample.
s1 - the sample below the central sample.
yfrac - the Y subsample position, in the range [0.0F, 1.0F).
Returns:
the interpolated value as a double.
Throws:
ArrayIndexOutOfBoundsException - if yfrac is out of bounds.

interpolateV

public double interpolateV(double s_,
                           double s0,
                           double s1,
                           double s2,
                           float yfrac)
Performs vertical interpolation on a quadruple of double samples. This method may be used instead of the array version for speed. It should only be called if height == 4 and keyY == 1. If yfrac does not lie between the range [0.0, 1.0F), an ArrayIndexOutOfBoundsException may occur.
Overrides:
interpolateV in class Interpolation
Parameters:
s_ - the sample above the central sample.
s0 - the central sample.
s1 - the sample below the central sample.
s2 - the sample below s1.
yfrac - the Y subsample position, in the range [0.0F, 1.0F).
Returns:
the interpolated value as a double.
Throws:
ArrayIndexOutOfBoundsException - if yfrac is out of bounds.

interpolate

public double interpolate(double s00,
                          double s01,
                          double s10,
                          double s11,
                          float xfrac,
                          float yfrac)
Performs interpolation on a 2x2 grid of double samples. It should only be called if width == height == 2 and keyX == keyY == 0. If either xfrac or yfrac does not lie between the range [0.0, 1.0F), an ArrayIndexOutOfBoundsException may occur.
Overrides:
interpolate in class Interpolation
Parameters:
s00 - the central sample.
s01 - the sample to the right of the central sample.
s10 - the sample below the central sample.
s11 - the sample below and to the right of the central sample.
xfrac - the X subsample position, in the range [0.0F, 1.0F).
yfrac - the Y subsample position, in the range [0.0F, 1.0F).
Returns:
the interpolated value as a double.
Throws:
ArrayIndexOutOfBoundsException - if xfrac or yfrac are out of bounds.

interpolate

public double interpolate(double s__,
                          double s_0,
                          double s_1,
                          double s_2,
                          double s0_,
                          double s00,
                          double s01,
                          double s02,
                          double s1_,
                          double s10,
                          double s11,
                          double s12,
                          double s2_,
                          double s20,
                          double s21,
                          double s22,
                          float xfrac,
                          float yfrac)
Performs interpolation on a 4x4 grid of double samples. It should only be called if width == height == 4 and keyX == keyY == 1. If either xfrac or yfrac does not lie between the range [0.0, 1.0F), an ArrayIndexOutOfBoundsException may occur.
Overrides:
interpolate in class Interpolation
Parameters:
s__ - the sample above and to the left of the central sample.
s_0 - the sample above the central sample.
s_1 - the sample above and one to the right of the central sample.
s_2 - the sample above and two to the right of the central sample.
s0_ - the sample to the left of the central sample.
s00 - the central sample.
s01 - the sample to the right of the central sample.
s02 - the sample two to the right of the central sample.
s1_ - the sample below and one to the left of the central sample.
s10 - the sample below the central sample.
s11 - the sample below and one to the right of the central sample.
s12 - the sample below and two to the right of the central sample.
s2_ - the sample two below and one to the left of the central sample.
s20 - the sample two below the central sample.
s21 - the sample two below and one to the right of the central sample.
s22 - the sample two below and two to the right of the central sample.
xfrac - the X subsample position, in the range [0.0F, 1.0F).
yfrac - the Y subsample position, in the range [0.0F, 1.0F).
Returns:
the interpolated value as a double.
Throws:
ArrayIndexOutOfBoundsException - if xfrac or yfrac are out of bounds.