Package com.xinapse.image
Class ColourVolumeInterpolator
java.lang.Object
com.xinapse.image.ColourVolumeInterpolator
An interpolator for a 3- (or fewer) dimensional array of pixels in a Colour image.
Supported pixel data types are:
The ColourVolumeInterpolator
interpolates to produce a set of interpolated colour
values at an arbitrary set of locations.
Supported interpolation types are:
InterpolationType.NEAREST_NEIGHBOUR
. Nearest neighbour interpolation.InterpolationType.LINEAR
. Tri-linear interpolation.InterpolationType.SINC
. Blackman-Harris windowed sinc interpolation.
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 colour value"
pixel colour. This missing colour value defaults to black, but can be set to any other
Color
. 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 ColourVolumeInterpolator
, and any pixel samples outside
the central
portion have a colour equal to the "missing colour value".
-
Constructor Summary
ConstructorDescriptionColourVolumeInterpolator
(byte[] pix, PixelDataType dataType, int nCols, int nRows, int nSlices, float pixelXSize, float pixelYSize, float pixelZSize, BoundaryCondition boundaryCondition, Color missingColourValue, InterpolationType interpolationType) Creates a newColourVolumeInterpolator
for a block of colour (R,G,B) pixel samples.ColourVolumeInterpolator
(ColourVolumeInterpolator interpolator, InterpolationType newType) Returns a newColourVolumeInterpolator
, constructed from an existing one. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
Signal to thisColourVolumeInterpolator
to stop the current interpolation (if an interpolation is in progress) as soon as possible.byte[]
interpolate
(float[] xyzArray, byte[] colourArray) Interpolate the intensity samples at a set of supplied coordinates.static void
Run the self-test for ColourVolumeInterpolator.
-
Constructor Details
-
ColourVolumeInterpolator
public ColourVolumeInterpolator(byte[] pix, PixelDataType dataType, int nCols, int nRows, int nSlices, float pixelXSize, float pixelYSize, float pixelZSize, BoundaryCondition boundaryCondition, Color missingColourValue, InterpolationType interpolationType) throws InstantiationException Creates a newColourVolumeInterpolator
for a block of colour (R,G,B) pixel samples.- Parameters:
pix
- the block of colour pixels 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.boundaryCondition
- theBoundaryCondition
to apply for interpolated points that are outside the block of pixels.missingColourValue
- the pixel value that will be set for interpolated points that are outside the block of pixels. Ifnull
, the default value ofColor.BLACK
will be set.interpolationType
- theInterpolationType
to be used for interpolation. One of:- Throws:
InstantiationException
- if theInterpolationType
is not supported.
-
ColourVolumeInterpolator
public ColourVolumeInterpolator(ColourVolumeInterpolator interpolator, InterpolationType newType) throws InstantiationException Returns a newColourVolumeInterpolator
, constructed from an existing one. This method can be used to change theInterpolationType
of an existingColourVolumeInterpolator
.- Parameters:
interpolator
- the existingColourVolumeInterpolator
.newType
- the newInterpolationType
to be used for interpolation. One of:- Throws:
InstantiationException
- if theInterpolationType
is not supported.
-
-
Method Details
-
cancel
public void cancel()Signal to thisColourVolumeInterpolator
to stop the current interpolation (if an interpolation is in progress) as soon as possible. -
interpolate
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.colourArray
- the array into which the interpolated pixel colours 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:
IndexOutOfBoundsException
- if the intensityArray is of the wrong length for the number of pixel (x,y,z) coordinates supplied.CancellationException
- if the interpolation halts prematurely because it has been cancelled.
-
main
Run the self-test for ColourVolumeInterpolator.- Parameters:
args
- ignored.
-