com.xinapse.multisliceimage
Class VolumeInterpolator

java.lang.Object
  extended by com.xinapse.multisliceimage.VolumeInterpolator

public abstract class VolumeInterpolator
extends java.lang.Object

An interpolator for a 3- (or fewer) dimensional array of pixels. Supported pixel data types are:

For Colour (R,G,B) images, use a ColourVolumeInterpolator.

The VolumeInterpolator always interpolates to produce a set of floating point interpolated values at an arbitrary set of locations, regardless of the PixelDataType of the pixel samples to be interpolated. For complex data types, the floating point values are in interleaved (real/imaginary) pairs and the length of the returned array of values is twice the number of locations to be interpolated.

Supported interpolation types are:

The origin (x=0, y=0, z=0) is assumed to be at the centre of the block of pixels, such that x values within the block go from x=-FoVx/2 to x=+FoVx/2 where FoVx is the field of view in the x-direction (with similar specification for y and z). The array of pixels to be interpolated is inset within the block such that there is half a pixel distance between the edges of the field of view and the first and last samples (i.e., FoVx = pixelXSize * number of columns, etc.).

Supplied coordinates outside the field of view will yield the "missing data value" pixel intensity. This missing data value defaults to zero, but can be set to any other (real) floating-point value. The result of any interpolation is the same as would result when iterpolating within an infinite array of pixel samples, where the central portion of samples is that supplied to form the VolumeInterpolator, and any pixel samples outside the central portion have an intensity equal to the "missing data value".


Field Summary
protected  PixelDataType dataType
          The PixelDataType of the pixel values to be interpolated.
protected  int nCols
          The number of columns in the block of pixels.
protected  int nRows
          The number of rows in the block of pixels.
protected  int nSlices
          The number of slices in the block of pixels.
protected  java.lang.Object pix
          The array of pixel values to be interpolated.
protected  float pixelXSize
          Horizontal pixel size in the block of pixels to be interpolated.
protected  float pixelYSize
          Vertical pixel size in the block of pixels to be interpolated.
protected  float pixelZSize
          Pixel depth in the block of pixels to be interpolated.
 
Method Summary
 void cancel()
          Signal to this VolumeInterpolator to stop the current interpolation (if an interpolation is in progress) as soon as possible, and throw a CancelledException.
static InterpolationType[] getImplementedTypes()
          Returns the types of interpolation that are implemented by the VolumeInterpolator class.
static VolumeInterpolator getInstance(java.lang.Object pix, PixelDataType dataType, int nCols, int nRows, int nSlices, float pixelXSize, float pixelYSize, float pixelZSize, java.lang.Float missingDataValue, InterpolationType type)
          Returns a new VolumeInterpolator for a block of pixel samples.
static VolumeInterpolator getInstance(java.lang.Object pix, PixelDataType dataType, int nCols, int nRows, int nSlices, float pixelXSize, float pixelYSize, float pixelZSize, InterpolationType type, java.lang.Float missingDataValue)
          Returns a new VolumeInterpolator for a block of pixel samples, with progress through the interpolation optionally being shown.
static VolumeInterpolator getInstance(VolumeInterpolator interpolator, InterpolationType newType)
          Returns a new VolumeInterpolator, constructed from an existing one.
static InterpolationType[] getSupportedInterpolationTypes()
          Returns an array of interpolation types currently supported by the VolumeInterpolator class.
abstract  float[] interpolate(float[] xyzArray, float[] intensityArray)
          Interpolate the intensity samples at a set of supplied coordinates.
static void main(java.lang.String[] argv)
          Run the test suite for VolumeInterpolator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pix

protected final java.lang.Object pix
The array of pixel values to be interpolated.


dataType

protected PixelDataType dataType
The PixelDataType of the pixel values to be interpolated.


nCols

protected int nCols
The number of columns in the block of pixels.


nRows

protected int nRows
The number of rows in the block of pixels.


nSlices

protected int nSlices
The number of slices in the block of pixels.


pixelXSize

protected float pixelXSize
Horizontal pixel size in the block of pixels to be interpolated.


pixelYSize

protected float pixelYSize
Vertical pixel size in the block of pixels to be interpolated.


pixelZSize

protected float pixelZSize
Pixel depth in the block of pixels to be interpolated.

Method Detail

cancel

public void cancel()
Signal to this VolumeInterpolator to stop the current interpolation (if an interpolation is in progress) as soon as possible, and throw a CancelledException.


getSupportedInterpolationTypes

public static InterpolationType[] getSupportedInterpolationTypes()
Returns an array of interpolation types currently supported by the VolumeInterpolator class.

Returns:
an array of interpolation types currently supported by the VolumeInterpolator class.

interpolate

public abstract float[] interpolate(float[] xyzArray,
                                    float[] intensityArray)
                             throws CancelledException
Interpolate the intensity samples at a set of supplied coordinates.

Parameters:
xyzArray - the x,y,z coordinates of each of the new sample locations. The x, y and z coordinates are supplied in interlaced order: x0, y0, z0, x1, y1, z1, .... xN-1, yN-1, zN-1.
intensityArray - the array into which the interpolated pixel intensities will be placed. If intensityArray is null, a new array will be allocated.
Returns:
the array of pixel intensities - either the newly-allocated one, or the one supplied. Pixel intensities are always returned as an array of float values, regardless of the data type of pixels to be interpolated.
Throws:
java.lang.IndexOutOfBoundsException - if the intensityArray is of the wrong length for the number of pixel (x,y,z) coordinates supplied.
CancelledException - if the interpolation halts prematurely because it has been cancelled.

getInstance

public static VolumeInterpolator getInstance(java.lang.Object pix,
                                             PixelDataType dataType,
                                             int nCols,
                                             int nRows,
                                             int nSlices,
                                             float pixelXSize,
                                             float pixelYSize,
                                             float pixelZSize,
                                             java.lang.Float missingDataValue,
                                             InterpolationType type)
                                      throws java.lang.InstantiationException
Returns a new VolumeInterpolator for a block of pixel samples.

Parameters:
pix - the set of intensities to be interpolated.
dataType - the PixelDataType of the block of pixels.
nCols - the number of columns in the block of pixels.
nRows - the number of rows in the block of pixels.
nSlices - the number of slices in the block of pixels.
pixelXSize - the pixel width.
pixelYSize - the pixel height.
pixelZSize - the pixel depth.
missingDataValue - the pixel value that that will be set for interpolated points that are outside the block of pixels. If null, the default value of 0.0 will be set.
type - the InterpolationType to be used for interpolation. One of:
  • InterpolationType.NEAREST_NEIGHBOUR.
  • InterpolationType.LINEAR.
  • InterpolationType.SINC.
Returns:
a VolumeInterpolator.
Throws:
java.lang.InstantiationException

getInstance

public static VolumeInterpolator getInstance(java.lang.Object pix,
                                             PixelDataType dataType,
                                             int nCols,
                                             int nRows,
                                             int nSlices,
                                             float pixelXSize,
                                             float pixelYSize,
                                             float pixelZSize,
                                             InterpolationType type,
                                             java.lang.Float missingDataValue)
                                      throws java.lang.InstantiationException
Returns a new VolumeInterpolator for a block of pixel samples, with progress through the interpolation optionally being shown.

Parameters:
pix - the set of intensities to be interpolated.
dataType - the PixelDataType of the block of pixels.
nCols - the number of columns in the block of pixels.
nRows - the number of rows in the block of pixels.
nSlices - the number of slices in the block of pixels.
pixelXSize - the pixel width.
pixelYSize - the pixel height.
pixelZSize - the pixel depth.
missingDataValue - the pixel value that that will be set for interpolated points that are outside the block of pixels. If null, the default value of 0.0 will be set.
type - the InterpolationType to be used for interpolation. One of:
  • InterpolationType.NEAREST_NEIGHBOUR.
  • InterpolationType.LINEAR.
  • InterpolationType.SINC.
Returns:
a VolumeInterpolator.
Throws:
java.lang.InstantiationException

getInstance

public static VolumeInterpolator getInstance(VolumeInterpolator interpolator,
                                             InterpolationType newType)
                                      throws java.lang.InstantiationException
Returns a new VolumeInterpolator, constructed from an existing one. This method can be used to change the IterpolationType of an existing VolumeInterpolator.

Parameters:
interpolator - the existing VolumeInterpolator.
newType - the new IterpolationType to be used for interpolation. One of:
  • InterpolationType.NEAREST_NEIGHBOUR.
  • InterpolationType.LINEAR.
  • InterpolationType.SINC.
Returns:
a VolumeInterpolator using the new type of interpolation.
Throws:
java.lang.InstantiationException

main

public static void main(java.lang.String[] argv)
Run the test suite for VolumeInterpolator.

Parameters:
argv - is ignored.

getImplementedTypes

public static InterpolationType[] getImplementedTypes()
Returns the types of interpolation that are implemented by the VolumeInterpolator class.

Returns:
an array of InterpolationTypes that can be used for volume interpolation.


Copyright 2006-2011 Xinapse Systems Limited. All Rights Reserved.