Class DoublePixArray

java.lang.Object
com.xinapse.image.PixArray
com.xinapse.image.DoublePixArray
All Implemented Interfaces:
Cloneable

public class DoublePixArray extends PixArray
A representation of an array of double-precision pixels.
  • Constructor Details

    • DoublePixArray

      protected DoublePixArray(int nDim, int[] dims, PixelDataType dataType)
      Creates an empty DoublePixArray object containing the number of pixels given by nDim and dims.
      Parameters:
      nDim - the dimensionality of the image.
      dims - the size of the image in each dimension.
      dataType - the PixelDataType that this DoublePixArray 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 the array 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 - the PixelDataType that this DoublePixArray 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 DataInputStream s, and containing the number of pixels specified in nDim and dims. The input stream must be correctly positioned at the start of the image data before calling this method.
      Parameters:
      s - the DataInputStream 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 - the PixelDataType that this DoublePixArray 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 RandomAccessFile f, and containing the number of pixels specified in nDim and dims.
      Parameters:
      f - the RandomAccessFile 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 - the PixelDataType that this DoublePixArray represents.
      Throws:
      IOException - if the array cannot be filled from the file.
  • Method Details

    • write

      public long write(DataOutputStream s, ByteOrder byteOrder) throws IOException
      Writes an DoublePixArray object to a DataOutputStream. All pixels are written.
      Specified by:
      write in class PixArray
      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

      public int[] getHisto(int nbins) throws InvalidImageException
      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 class PixArray
      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 class PixArray
      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 accessed
      highIdx - contains indexes to the highest index of the image pixel array that is required to be accessed
      op - 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

      public Object getPutSlice(Object array, int slice, PixelOp op) throws IllegalArgumentException
      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 class PixArray
      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

      public Object getPutPix(Object pix, int[] pixIdx, PixelOp op) throws IllegalArgumentException
      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 class PixArray
      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.