|
|
Sloan Digital Sky Survey |
| IVOA FITS Package | |
ImageInputStreamInputStream now throws IOException if
it runs into problems, and the public static method
gunzipIfNecessary(InputStream in) has been moved
from the FITSReader class into the
ImageInputStreamInputStream class and has been made protected.
Application developers using these classes and/or methods should update
affected code accordingly. Everyone else should be able to disregard this
notice.
static
{
IIORegistry.getDefaultInstance().
registerServiceProvider(new FITSReaderSpi());
}
This code should be placed in some class that is guaranteed to be loaded before
any FITS images are loaded. A FITS image can then be loaded using the normal
Java ImageIO interface, as follows:
BufferedImage image = ImageIO.read(in);
This will load any type of image supported natively by Java, as well as FITS
images, provided that the SPI implementation has been registered as described
above. To determine whether the image loaded is indeed a FITS image and to get
a reference of the proper type, do something like the following:
if(image instanceof FITSImage)
{
FITSImage fitsImage = (FITSImage)image;
}
Here it should be clear that FITSImage is a subclass of BufferedImage, and can
be treated as such. But to get any real use out of the image, it should be cast
to FITSImage so that the extended functionality can be used. The SampleModel of
the image will most likely (and should) be a PixelInterleavedSampleModel, and
the ColorModel will be in the CS_sRGB color space with data type USHORT. These
images can be displayed in any Java Component as is, but you will probably want
to add your own colormap functionality to reduce them to byte range. As the
resulting data is in the USHORT range, obviously many images must internally be
scaled to that range, thus there are several common scaling algorithms offered
as well as one relatively new one. These are explained in more detail in the
javadocs for FITSImage. With each FITSImage comes
associated a Histogram which can be used for various image intensity scaling
purposes. The number of bins in the Histogram is 65535.
java -Xmx128M -jar ivoafits-0.3.jar filename.fitsHere "filename.fits" of course should be replaced by the name of some actual image file. There is optional debugging output which prints the execution time of each rescaling. This option may be turned on by including the following argument to the above java command:
-Ddebug=on
| IVOA FITS Package | Executable jar which runs the example mentioned above, and is the distribution jar of the package itself. |
| IVOA FITS Package Source Distribution | Source code for those who are interested. |
| IVOA FITS Package | Executable jar which runs the example mentioned above, and is the distribution jar of the package itself. |
| IVOA FITS Package Source Distribution | Source code for those who are interested. |
Samuel Carliles
Last Modified :Tuesday, September 12, 2006 at 5:00:53 PM
, $Revision 1.7 $