Class ShortPixArray

java.lang.Object
com.xinapse.image.PixArray
com.xinapse.image.ShortPixArray
Direct Known Subclasses:
UShortPixArray

class ShortPixArray extends PixArray
A representation of an array of signed short pixels.
  • Method Details

    • write

      public long write(BufferedOutputStream s, ByteOrder byteOrder) throws IOException
      Writes a ShortPixArray object to a BufferedOutputStream. All pixels are written.
      Specified by:
      write in class PixArray
      Parameters:
      s - the BufferedOutputStream.
      byteOrder - the ByteOrder of the data in the output 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 ShortPixArray. This works properly if the pixel intensity range is less than the number of bins requested: if not then all the high intensity pixels are put into the last histogram bin.
      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)
      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 (exclusive) 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 {6, 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 (GET or PUT).
      Returns:
      a 1-dimensional short array cast to an Object.
      Throws:
      IllegalArgumentException - the class of the pix 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 short, 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 is 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 short 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 Short 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.