Package com.xinapse.image
Class DoublePixArray
java.lang.Object
com.xinapse.image.PixArray
com.xinapse.image.DoublePixArray
- All Implemented Interfaces:
Cloneable
A representation of an array of double-precision pixels.
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
DoublePixArray
(int nDim, int[] dims, PixelDataType dataType) Creates an empty DoublePixArray object containing the number of pixels given bynDim
anddims
.protected
DoublePixArray
(DataInputStream s, ByteOrder byteOrder, int nDim, int[] dims, PixelDataType dataType) Creates an DoublePixArray object, with the pixel intensity data coming from DataInputStreams
, and containing the number of pixels specified innDim
anddims
.protected
DoublePixArray
(RandomAccessFile f, ByteOrder byteOrder, int offset, int nDim, int[] dims, PixelDataType dataType) Creates an DoublePixArray object, with the pixel intensity data coming from RandomAccessFilef
, and containing the number of pixels specified innDim
anddims
.protected
DoublePixArray
(Object array, int nDim, int[] dims, PixelDataType dataType) Creates an empty DoublePixArray object with enough pixels to contain the whole of the image. -
Method Summary
Modifier and TypeMethodDescriptionint[]
getHisto
(int nbins) Computes a histogram of a DoublePixArray.Basic pixel accessor method for images of any dimensionality.Gets/puts a single pixel value from/to an an image.getPutSlice
(Object array, int slice, PixelOp op) Returns a 1-Dimensional array of type int, cast as an Object, with array indices [0 to (nRows * nCols)-1], representing the pixel intensity values for one slice of this image.static void
sincInterpolate
(double[] origIntensities, double[] regriddedIntensities, float[] gridPt) Sinc interpolate a set of pixel intensities onto a new set of grid points.long
write
(DataOutputStream s, ByteOrder byteOrder) Writes an DoublePixArray object to a DataOutputStream.Methods inherited from class com.xinapse.image.PixArray
__getPix, clone, getInstance, getInstance, getInstance, getMinMax, getPix, getPutPix, getPutPix, getPutSlice
-
Constructor Details
-
DoublePixArray
Creates an empty DoublePixArray object containing the number of pixels given bynDim
anddims
.- Parameters:
nDim
- the dimensionality of the image.dims
- the size of the image in each dimension.dataType
- thePixelDataType
that thisDoublePixArray
represents.
-
DoublePixArray
protected DoublePixArray(Object array, int nDim, int[] dims, PixelDataType dataType) throws IllegalArgumentException Creates an empty DoublePixArray object with enough pixels to contain the whole of the image. Will reuse thearray
for the pixel data if this is non-null- Parameters:
array
- an array of int pixels to reuse.nDim
- the dimensionality of the image.dims
- the size of the image in each dimension.dataType
- thePixelDataType
that thisDoublePixArray
represents.- Throws:
IllegalArgumentException
- if the supplied array is of the incorrect size.
-
DoublePixArray
protected DoublePixArray(DataInputStream s, ByteOrder byteOrder, int nDim, int[] dims, PixelDataType dataType) throws IOException Creates an DoublePixArray object, with the pixel intensity data coming from DataInputStreams
, and containing the number of pixels specified innDim
anddims
. The input stream must be correctly positioned at the start of the image data before calling this method.- Parameters:
s
- theDataInputStream
that will supply the pixel data.byteOrder
- the ByteOrder of the data in the input stream.nDim
- the dimensionality of the image.dims
- the size of the image in each dimension.dataType
- thePixelDataType
that thisDoublePixArray
represents.- Throws:
IOException
- if the end of the DataInputStream is reached before the array is filled.
-
DoublePixArray
protected DoublePixArray(RandomAccessFile f, ByteOrder byteOrder, int offset, int nDim, int[] dims, PixelDataType dataType) throws IOException Creates an DoublePixArray object, with the pixel intensity data coming from RandomAccessFilef
, and containing the number of pixels specified innDim
anddims
.- Parameters:
f
- theRandomAccessFile
containing the pixel data.byteOrder
- the ByteOrder of the data in the file.offset
- the offset in bytes from the start of the file to the zero'th pixel.nDim
- the dimensionality of the image.dims
- the size of the image in each dimension.dataType
- thePixelDataType
that thisDoublePixArray
represents.- Throws:
IOException
- if the array cannot be filled from the file.
-
-
Method Details
-
write
Writes an DoublePixArray object to a DataOutputStream. All pixels are written.- Specified by:
write
in classPixArray
- Parameters:
s
- the DataOutputStream.byteOrder
- the ByteOrder of the data in the input stream.- Returns:
- the number of bytes written.
- Throws:
IOException
- if the data cannot be written.
-
getHisto
Computes a histogram of a DoublePixArray. This works properly if the pixel intensity range is less than the number of bins requested; if not then a InvalidImageException is thrown.- Specified by:
getHisto
in classPixArray
- Parameters:
nbins
- the number of bins in the histogram.- Returns:
- an int[] of length 2 where first element is the number of pixels of intensity min pixel, and the bins are in steps of 1 intensity init.
- Throws:
InvalidImageException
- if the histogram can't be computed.
-
getPutPix
public Object getPutPix(Object arrayToReuse, int[] lowIdx, int[] highIdx, PixelOp op) throws IllegalArgumentException Description copied from class:PixArray
Basic pixel accessor method for images of any dimensionality. The int[] lowIdx contains indexes to the lowest index of the image pixel array that is required to be accessed, and highIdx indexes to the highest index of the image pixel array that is required to be accessed. Only image dimensions from lowIdx to highIdx are accessed. For example, if you have a 10-slice 256x256 3-dimensional image and want the pixel values for just slices 2 to 5, then lowIdx would have values {2, 0, 0} and highIdx would have values {5, 255, 255}.- Specified by:
getPutPix
in classPixArray
- Parameters:
arrayToReuse
- for get operations is an array to put pixels values in; for put operations contains the pixel values to put.lowIdx
- contains indexes to the lowest index of the image pixel array that is required to be accessedhighIdx
- contains indexes to the highest index of the image pixel array that is required to be accessedop
- the type of operation (PixelOp.GET or PixelOp.PUT).- Returns:
- a 1-dimensional array of the appropriate type cast to an Object.
- Throws:
IllegalArgumentException
- if the class of the array is incorrect for this type of image.
-
getPutSlice
Returns a 1-Dimensional array of type int, cast as an Object, with array indices [0 to (nRows * nCols)-1], representing the pixel intensity values for one slice of this image. Applicable only to images with dimensionality of 2 or greater. If the image has dimensionality of greater than three, then this routine pretends that the image contains a just one multi-slice image, where in fact it contains series of multi-slice images - one for each of the extra dimensions. These can be accessed by providing a slice-number argument appropriate for the dimensionality of the image. For example, if the image is 4-dimensional with dimensions 10, 20, 256, 256, then this consists of ten 3-D images each with 20 slices of 256x256 pixels. This routine pretends that thus is a 3-D image with 10x20 (=200) slices, so any slice from 0-199 could be accessed.- Specified by:
getPutSlice
in classPixArray
- Parameters:
array
- for get operations is an array to put pixels values in; for put operations contains the pixel values to put.slice
- the slice number.op
- the type of operation (GET or PUT).- Returns:
- a 1-dimensional int array cast to an Object.
- Throws:
IllegalArgumentException
- if the requested pixel values cannot be put or got.
-
getPutPix
Gets/puts a single pixel value from/to an an image. Returns a java.lang.Double cast to Object corresponding to the picture primitve type. This represents the pixel intensity value for the pixel indexed by each element of pixIdx.- Specified by:
getPutPix
in classPixArray
- Parameters:
pix
- a pixel value for a put operation or null for a get operation.pixIdx
- an array of length at least nDim with elements 0 to nDim-1 equal to the index in that image dimension.op
- the type of operation (GET or PUT).- Returns:
- a pixel value for a get operation or the supplied pixel for a put operation.
- Throws:
IllegalArgumentException
- if the pixIdx is bad.
-
sincInterpolate
public static void sincInterpolate(double[] origIntensities, double[] regriddedIntensities, float[] gridPt) Sinc interpolate a set of pixel intensities onto a new set of grid points. The original grid points are assumed to be 0, 1, 2, 3, 4,...etc.- Parameters:
origIntensities
- contains the pixel intensities of the input grid.regriddedIntensities
- contains the pixel intensities in the resampled grid.gridPt
- specifies the grid points of the pixels sample locations in the resampled grid.
-