skyview.survey
Class HDecompressor

java.lang.Object
  extended by skyview.survey.HDecompressor

public class HDecompressor
extends java.lang.Object

HDecompressor. Uncompress astronomical images compressed using the H-compression algorithm. Examples :

          DataInputStream dis = new DataInputStream( new FileInputStream(arg[0]));
          byte [] pixels=Hdecomp.decomp( (InputStream)dis );
 
where the user needs to translate the byte stream back into a series of shorts.
          DataInputStream dis = new DataInputStream( new FileInputStream(arg[0]));
          Hdecomp         hd  = new Hdecomp(dis);
          hd.decomp();
          int[] pixels        =  hd.getImage();
          int   nx            =  hd.getNx();
          int   ny            =  hd.getNy();
 


Constructor Summary
HDecompressor()
          Create a bare decompressor object.
HDecompressor(java.io.InputStream dis)
          Create a decompressor associating it with a given input stream.
 
Method Summary
 void decompress()
          Decompress the input stream.
static int[] decompress(java.io.InputStream fdis)
          Hdecompress static method.
 int[] getImage()
          Get decompressed image as a one-d array of ints.
 int getNx()
          Get the X-dimension of the decompressed image.
 int getNy()
          Get the Y-dimension of the decompressed image.
 void setInputStream(java.io.InputStream dis)
          Set the input stream for an Hdecomp object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HDecompressor

public HDecompressor()
Create a bare decompressor object.


HDecompressor

public HDecompressor(java.io.InputStream dis)
Create a decompressor associating it with a given input stream.

Parameters:
dis - The input stream from which the compressed data is derived.
Method Detail

setInputStream

public void setInputStream(java.io.InputStream dis)
Set the input stream for an Hdecomp object.

Parameters:
dis - The input stream from which the compressed data is derived.

decompress

public static int[] decompress(java.io.InputStream fdis)
                        throws java.lang.Exception
Hdecompress static method.

Parameters:
fdis - The input stream from which compressed data is to be extracted. It should begin with the magic characters [0xDD, 0x99]. If the compressed data is preceded by a FITS header it is the responsibility of the program to skip past the header before calling this routine.
Returns:
byte[] The uncompressed Fits image. Note that this image is actually an array of shorts and the calling program should combine pairs of bytes to get the value for each pixel.
Throws:
java.lang.Exception

decompress

public void decompress()
                throws java.lang.Exception
Decompress the input stream. The result is left in the a[] array and can be accessed using the various get methods.

Throws:
java.lang.Exception

getNx

public int getNx()
Get the X-dimension of the decompressed image.

Returns:
The number of columns in the image.

getNy

public int getNy()
Get the Y-dimension of the decompressed image.

Returns:
The number of rows in the image.

getImage

public int[] getImage()
Get decompressed image as a one-d array of ints. Note that this returns a pointer to the internal array. If another image is compressed it may overwrite the current image in place. The caller should copy the array if multiple files are being decompressed using the same Hdecomp object.

Returns:
The decompressed image as a 1-D int array.