jfits
Class BufferedFitsImage

java.lang.Object
  extended by java.awt.Image
      extended by java.awt.image.BufferedImage
          extended by jfits.BufferedFitsImage
All Implemented Interfaces:
RenderedImage, WritableRenderedImage, Transparency

public class BufferedFitsImage
extends BufferedImage

This class is based on the IVOA Fits package. The only difference is that we are not using a RGB color space, but a GRAY color space. This saves memory, but does not speed up the methods.


Nested Class Summary
static class BufferedFitsImage.DataTypeNotSupportedException
           
static class BufferedFitsImage.NoImageDataFoundException
           
 
Field Summary
protected  BufferedImage _delegate
           
protected  nom.tam.fits.Fits _fits
           
protected  nom.tam.fits.BasicHDU[] _hdus
           
protected  FitsHistogram _histogram
           
protected  nom.tam.fits.ImageHDU _imageHDU
           
protected  double _max
           
protected  double _min
           
protected  short[] _scaledData
           
protected  int _scaleMethod
           
protected  double _sigma
           
protected  int _type
           
static int skip
          For multiple extension fits, this is the number of ImageHDU to skip.
 
Fields inherited from class java.awt.image.BufferedImage
TYPE_3BYTE_BGR, TYPE_4BYTE_ABGR, TYPE_4BYTE_ABGR_PRE, TYPE_BYTE_BINARY, TYPE_BYTE_GRAY, TYPE_BYTE_INDEXED, TYPE_CUSTOM, TYPE_INT_ARGB, TYPE_INT_ARGB_PRE, TYPE_INT_BGR, TYPE_INT_RGB, TYPE_USHORT_555_RGB, TYPE_USHORT_565_RGB, TYPE_USHORT_GRAY
 
Fields inherited from class java.awt.Image
accelerationPriority, SCALE_AREA_AVERAGING, SCALE_DEFAULT, SCALE_FAST, SCALE_REPLICATE, SCALE_SMOOTH, UndefinedProperty
 
Fields inherited from interface java.awt.Transparency
BITMASK, OPAQUE, TRANSLUCENT
 
Constructor Summary
BufferedFitsImage(File file)
           
BufferedFitsImage(File file, int scaleMethod)
           
BufferedFitsImage(nom.tam.fits.Fits fits)
           
BufferedFitsImage(nom.tam.fits.Fits fits, BufferedImage delegate, int scaleMethod, int type)
           
BufferedFitsImage(nom.tam.fits.Fits fits, int scaleMethod)
           
BufferedFitsImage(nom.tam.fits.Fits fits, int scaleMethod, int type)
           
BufferedFitsImage(String filename)
           
BufferedFitsImage(String filename, int scaleMethod)
           
BufferedFitsImage(URL url)
           
BufferedFitsImage(URL url, int scaleMethod)
           
 
Method Summary
 WritableRaster copyData(WritableRaster outRaster)
           
 Graphics2D createGraphics()
           
protected static BufferedImage createScaledImage(nom.tam.fits.Fits fits, int scaleMethod, int type)
           
static BufferedImage createScaledImage(nom.tam.fits.ImageHDU hdu, int scaleMethod, int type)
           
static BufferedImage createScaledImage(nom.tam.fits.ImageHDU hdu, short[] result, FitsHistogram hist, double min, double max, double sigma, int scaleMethod, int colortype)
          Creates a buffered image with color space type gray.
static BufferedImage createScaledImage(nom.tam.fits.ImageHDU hdu, short[] result, FitsHistogram hist, double min, double max, double sigma, int scaleMethod, int colortype, int datatype)
          Creates a buffered image with color space type gray.
protected static nom.tam.fits.ImageHDU findFirstImageHDU(nom.tam.fits.Fits fits)
           
 void flush()
           
 WritableRaster getAlphaRaster()
           
 ColorModel getColorModel()
           
 Raster getData()
           
 Raster getData(Rectangle rect)
           
protected  BufferedImage getDelegate()
           
 nom.tam.fits.Fits getFits()
           
 Graphics getGraphics()
           
 int getHeight()
           
 int getHeight(ImageObserver observer)
           
 FitsHistogram getHistogram()
           
 nom.tam.fits.ImageHDU getImageHDU()
           
 int getMinTileX()
           
 int getMinTileY()
           
 int getMinX()
           
 int getMinY()
           
 int getNumXTiles()
           
 int getNumYTiles()
           
 double getOriginalValue(int x, int y)
           
 Object getProperty(String name)
           
 Object getProperty(String name, ImageObserver observer)
           
 String[] getPropertyNames()
           
 WritableRaster getRaster()
           
 int getRGB(int x, int y)
           
 int[] getRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize)
           
 SampleModel getSampleModel()
           
 int getScaleMethod()
           
static String[] getScaleNames()
           
 ImageProducer getSource()
           
 Vector getSources()
           
 BufferedImage getSubimage(int x, int y, int w, int h)
           
 Raster getTile(int tileX, int tileY)
           
 int getTileGridXOffset()
           
 int getTileGridYOffset()
           
 int getTileHeight()
           
 int getTileWidth()
           
 int getType()
           
 int getWidth()
           
 int getWidth(ImageObserver observer)
           
 WritableRaster getWritableTile(int tileX, int tileY)
           
 Point[] getWritableTileIndices()
           
 boolean hasTileWriters()
           
 boolean isAlphaPremultiplied()
           
 boolean isTileWritable(int tileX, int tileY)
           
 void releaseWritableTile(int tileX, int tileY)
           
 void rescale(double min, double max)
           
 void rescale(double min, double max, double sigma)
           
 void rescale(JHistogram.Bounds percent)
           
static String revision()
           
 void setData(Raster r)
           
protected  void setDelegate(BufferedImage delegate)
           
protected  void setFits(nom.tam.fits.Fits fits)
           
protected  void setHistogram(FitsHistogram histogram)
           
protected  void setImageHDU(nom.tam.fits.ImageHDU imageHDU)
           
 void setRGB(int x, int y, int rgb)
           
 void setRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize)
           
 void setScaleMethod(int scaleMethod)
           
 String toString()
           
 
Methods inherited from class java.awt.image.BufferedImage
addTileObserver, coerceData, getTransparency, removeTileObserver
 
Methods inherited from class java.awt.Image
getAccelerationPriority, getCapabilities, getScaledInstance, setAccelerationPriority
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

skip

public static int skip
For multiple extension fits, this is the number of ImageHDU to skip.


_fits

protected nom.tam.fits.Fits _fits

_imageHDU

protected nom.tam.fits.ImageHDU _imageHDU

_hdus

protected nom.tam.fits.BasicHDU[] _hdus

_scaleMethod

protected int _scaleMethod

_type

protected int _type

_scaledData

protected short[] _scaledData

_sigma

protected double _sigma

_min

protected double _min

_max

protected double _max

_histogram

protected FitsHistogram _histogram

_delegate

protected BufferedImage _delegate
Constructor Detail

BufferedFitsImage

public BufferedFitsImage(nom.tam.fits.Fits fits)
                  throws nom.tam.fits.FitsException,
                         BufferedFitsImage.DataTypeNotSupportedException,
                         BufferedFitsImage.NoImageDataFoundException,
                         IOException
Throws:
nom.tam.fits.FitsException
BufferedFitsImage.DataTypeNotSupportedException
BufferedFitsImage.NoImageDataFoundException
IOException

BufferedFitsImage

public BufferedFitsImage(nom.tam.fits.Fits fits,
                         int scaleMethod)
                  throws nom.tam.fits.FitsException,
                         BufferedFitsImage.DataTypeNotSupportedException,
                         BufferedFitsImage.NoImageDataFoundException,
                         IOException
Throws:
nom.tam.fits.FitsException
BufferedFitsImage.DataTypeNotSupportedException
BufferedFitsImage.NoImageDataFoundException
IOException

BufferedFitsImage

public BufferedFitsImage(nom.tam.fits.Fits fits,
                         int scaleMethod,
                         int type)
                  throws nom.tam.fits.FitsException,
                         BufferedFitsImage.DataTypeNotSupportedException,
                         BufferedFitsImage.NoImageDataFoundException,
                         IOException
Throws:
nom.tam.fits.FitsException
BufferedFitsImage.DataTypeNotSupportedException
BufferedFitsImage.NoImageDataFoundException
IOException

BufferedFitsImage

public BufferedFitsImage(nom.tam.fits.Fits fits,
                         BufferedImage delegate,
                         int scaleMethod,
                         int type)
                  throws nom.tam.fits.FitsException,
                         BufferedFitsImage.DataTypeNotSupportedException,
                         BufferedFitsImage.NoImageDataFoundException,
                         IOException
Throws:
nom.tam.fits.FitsException
BufferedFitsImage.DataTypeNotSupportedException
BufferedFitsImage.NoImageDataFoundException
IOException

BufferedFitsImage

public BufferedFitsImage(File file)
                  throws nom.tam.fits.FitsException,
                         BufferedFitsImage.DataTypeNotSupportedException,
                         BufferedFitsImage.NoImageDataFoundException,
                         IOException
Throws:
nom.tam.fits.FitsException
BufferedFitsImage.DataTypeNotSupportedException
BufferedFitsImage.NoImageDataFoundException
IOException

BufferedFitsImage

public BufferedFitsImage(File file,
                         int scaleMethod)
                  throws nom.tam.fits.FitsException,
                         BufferedFitsImage.DataTypeNotSupportedException,
                         BufferedFitsImage.NoImageDataFoundException,
                         IOException
Throws:
nom.tam.fits.FitsException
BufferedFitsImage.DataTypeNotSupportedException
BufferedFitsImage.NoImageDataFoundException
IOException

BufferedFitsImage

public BufferedFitsImage(String filename)
                  throws nom.tam.fits.FitsException,
                         BufferedFitsImage.DataTypeNotSupportedException,
                         BufferedFitsImage.NoImageDataFoundException,
                         IOException
Throws:
nom.tam.fits.FitsException
BufferedFitsImage.DataTypeNotSupportedException
BufferedFitsImage.NoImageDataFoundException
IOException

BufferedFitsImage

public BufferedFitsImage(String filename,
                         int scaleMethod)
                  throws nom.tam.fits.FitsException,
                         BufferedFitsImage.DataTypeNotSupportedException,
                         BufferedFitsImage.NoImageDataFoundException,
                         IOException
Throws:
nom.tam.fits.FitsException
BufferedFitsImage.DataTypeNotSupportedException
BufferedFitsImage.NoImageDataFoundException
IOException

BufferedFitsImage

public BufferedFitsImage(URL url)
                  throws nom.tam.fits.FitsException,
                         BufferedFitsImage.DataTypeNotSupportedException,
                         BufferedFitsImage.NoImageDataFoundException,
                         IOException
Throws:
nom.tam.fits.FitsException
BufferedFitsImage.DataTypeNotSupportedException
BufferedFitsImage.NoImageDataFoundException
IOException

BufferedFitsImage

public BufferedFitsImage(URL url,
                         int scaleMethod)
                  throws nom.tam.fits.FitsException,
                         BufferedFitsImage.DataTypeNotSupportedException,
                         BufferedFitsImage.NoImageDataFoundException,
                         IOException
Throws:
nom.tam.fits.FitsException
BufferedFitsImage.DataTypeNotSupportedException
BufferedFitsImage.NoImageDataFoundException
IOException
Method Detail

getScaleNames

public static String[] getScaleNames()

getFits

public nom.tam.fits.Fits getFits()

getImageHDU

public nom.tam.fits.ImageHDU getImageHDU()

setHistogram

protected void setHistogram(FitsHistogram histogram)

getHistogram

public FitsHistogram getHistogram()

getOriginalValue

public double getOriginalValue(int x,
                               int y)
                        throws nom.tam.fits.FitsException
Throws:
nom.tam.fits.FitsException

getScaleMethod

public int getScaleMethod()

setScaleMethod

public void setScaleMethod(int scaleMethod)

rescale

public void rescale(JHistogram.Bounds percent)

rescale

public void rescale(double min,
                    double max)

rescale

public void rescale(double min,
                    double max,
                    double sigma)

getDelegate

protected BufferedImage getDelegate()

setDelegate

protected void setDelegate(BufferedImage delegate)

copyData

public WritableRaster copyData(WritableRaster outRaster)
Specified by:
copyData in interface RenderedImage
Overrides:
copyData in class BufferedImage

createGraphics

public Graphics2D createGraphics()
Overrides:
createGraphics in class BufferedImage

flush

public void flush()
Overrides:
flush in class Image

getAlphaRaster

public WritableRaster getAlphaRaster()
Overrides:
getAlphaRaster in class BufferedImage

getColorModel

public ColorModel getColorModel()
Specified by:
getColorModel in interface RenderedImage
Overrides:
getColorModel in class BufferedImage

getData

public Raster getData()
Specified by:
getData in interface RenderedImage
Overrides:
getData in class BufferedImage

getData

public Raster getData(Rectangle rect)
Specified by:
getData in interface RenderedImage
Overrides:
getData in class BufferedImage

getGraphics

public Graphics getGraphics()
Overrides:
getGraphics in class BufferedImage

getHeight

public int getHeight()
Specified by:
getHeight in interface RenderedImage
Overrides:
getHeight in class BufferedImage

getHeight

public int getHeight(ImageObserver observer)
Overrides:
getHeight in class BufferedImage

getMinTileX

public int getMinTileX()
Specified by:
getMinTileX in interface RenderedImage
Overrides:
getMinTileX in class BufferedImage

getMinTileY

public int getMinTileY()
Specified by:
getMinTileY in interface RenderedImage
Overrides:
getMinTileY in class BufferedImage

getMinX

public int getMinX()
Specified by:
getMinX in interface RenderedImage
Overrides:
getMinX in class BufferedImage

getMinY

public int getMinY()
Specified by:
getMinY in interface RenderedImage
Overrides:
getMinY in class BufferedImage

getNumXTiles

public int getNumXTiles()
Specified by:
getNumXTiles in interface RenderedImage
Overrides:
getNumXTiles in class BufferedImage

getNumYTiles

public int getNumYTiles()
Specified by:
getNumYTiles in interface RenderedImage
Overrides:
getNumYTiles in class BufferedImage

getProperty

public Object getProperty(String name)
Specified by:
getProperty in interface RenderedImage
Overrides:
getProperty in class BufferedImage

getProperty

public Object getProperty(String name,
                          ImageObserver observer)
Overrides:
getProperty in class BufferedImage

getPropertyNames

public String[] getPropertyNames()
Specified by:
getPropertyNames in interface RenderedImage
Overrides:
getPropertyNames in class BufferedImage

getRaster

public WritableRaster getRaster()
Overrides:
getRaster in class BufferedImage

getRGB

public int getRGB(int x,
                  int y)
Overrides:
getRGB in class BufferedImage

getRGB

public int[] getRGB(int startX,
                    int startY,
                    int w,
                    int h,
                    int[] rgbArray,
                    int offset,
                    int scansize)
Overrides:
getRGB in class BufferedImage

getSampleModel

public SampleModel getSampleModel()
Specified by:
getSampleModel in interface RenderedImage
Overrides:
getSampleModel in class BufferedImage

getSource

public ImageProducer getSource()
Overrides:
getSource in class BufferedImage

getSources

public Vector getSources()
Specified by:
getSources in interface RenderedImage
Overrides:
getSources in class BufferedImage

getSubimage

public BufferedImage getSubimage(int x,
                                 int y,
                                 int w,
                                 int h)
Overrides:
getSubimage in class BufferedImage

getTile

public Raster getTile(int tileX,
                      int tileY)
Specified by:
getTile in interface RenderedImage
Overrides:
getTile in class BufferedImage

getTileGridXOffset

public int getTileGridXOffset()
Specified by:
getTileGridXOffset in interface RenderedImage
Overrides:
getTileGridXOffset in class BufferedImage

getTileGridYOffset

public int getTileGridYOffset()
Specified by:
getTileGridYOffset in interface RenderedImage
Overrides:
getTileGridYOffset in class BufferedImage

getTileHeight

public int getTileHeight()
Specified by:
getTileHeight in interface RenderedImage
Overrides:
getTileHeight in class BufferedImage

getTileWidth

public int getTileWidth()
Specified by:
getTileWidth in interface RenderedImage
Overrides:
getTileWidth in class BufferedImage

getType

public int getType()
Overrides:
getType in class BufferedImage

getWidth

public int getWidth()
Specified by:
getWidth in interface RenderedImage
Overrides:
getWidth in class BufferedImage

getWidth

public int getWidth(ImageObserver observer)
Overrides:
getWidth in class BufferedImage

getWritableTile

public WritableRaster getWritableTile(int tileX,
                                      int tileY)
Specified by:
getWritableTile in interface WritableRenderedImage
Overrides:
getWritableTile in class BufferedImage

getWritableTileIndices

public Point[] getWritableTileIndices()
Specified by:
getWritableTileIndices in interface WritableRenderedImage
Overrides:
getWritableTileIndices in class BufferedImage

hasTileWriters

public boolean hasTileWriters()
Specified by:
hasTileWriters in interface WritableRenderedImage
Overrides:
hasTileWriters in class BufferedImage

isAlphaPremultiplied

public boolean isAlphaPremultiplied()
Overrides:
isAlphaPremultiplied in class BufferedImage

isTileWritable

public boolean isTileWritable(int tileX,
                              int tileY)
Specified by:
isTileWritable in interface WritableRenderedImage
Overrides:
isTileWritable in class BufferedImage

releaseWritableTile

public void releaseWritableTile(int tileX,
                                int tileY)
Specified by:
releaseWritableTile in interface WritableRenderedImage
Overrides:
releaseWritableTile in class BufferedImage

setData

public void setData(Raster r)
Specified by:
setData in interface WritableRenderedImage
Overrides:
setData in class BufferedImage

setRGB

public void setRGB(int x,
                   int y,
                   int rgb)
Overrides:
setRGB in class BufferedImage

setRGB

public void setRGB(int startX,
                   int startY,
                   int w,
                   int h,
                   int[] rgbArray,
                   int offset,
                   int scansize)
Overrides:
setRGB in class BufferedImage

toString

public String toString()
Overrides:
toString in class BufferedImage

setFits

protected void setFits(nom.tam.fits.Fits fits)

setImageHDU

protected void setImageHDU(nom.tam.fits.ImageHDU imageHDU)

findFirstImageHDU

protected static nom.tam.fits.ImageHDU findFirstImageHDU(nom.tam.fits.Fits fits)
                                                  throws nom.tam.fits.FitsException,
                                                         IOException
Throws:
nom.tam.fits.FitsException
IOException

createScaledImage

protected static BufferedImage createScaledImage(nom.tam.fits.Fits fits,
                                                 int scaleMethod,
                                                 int type)
                                          throws nom.tam.fits.FitsException,
                                                 BufferedFitsImage.DataTypeNotSupportedException,
                                                 BufferedFitsImage.NoImageDataFoundException,
                                                 IOException
Throws:
nom.tam.fits.FitsException
BufferedFitsImage.DataTypeNotSupportedException
BufferedFitsImage.NoImageDataFoundException
IOException

createScaledImage

public static BufferedImage createScaledImage(nom.tam.fits.ImageHDU hdu,
                                              int scaleMethod,
                                              int type)
                                       throws nom.tam.fits.FitsException,
                                              BufferedFitsImage.DataTypeNotSupportedException
Returns:
An array of BufferedImages from hdu with intensity values scaled to short range using linear, log, square root, and square scales, in that order.
Throws:
nom.tam.fits.FitsException
BufferedFitsImage.DataTypeNotSupportedException

createScaledImage

public static BufferedImage createScaledImage(nom.tam.fits.ImageHDU hdu,
                                              short[] result,
                                              FitsHistogram hist,
                                              double min,
                                              double max,
                                              double sigma,
                                              int scaleMethod,
                                              int colortype)
                                       throws nom.tam.fits.FitsException,
                                              BufferedFitsImage.DataTypeNotSupportedException
Creates a buffered image with color space type gray. This is the most memory efficient method, but it does not behave well under scaling. In particular, scaling to non-integer values brightens points. This behaviour is found with jdk1.4.2 and 1.5.0.6 on linux debian and is probably due to the native filter library. It can be circumvented, though, if the buffered image is promoted to sRGB, resulting in three times the memory consumption, as each point shows up as equal value in the gray lavel.

Throws:
nom.tam.fits.FitsException
BufferedFitsImage.DataTypeNotSupportedException

createScaledImage

public static BufferedImage createScaledImage(nom.tam.fits.ImageHDU hdu,
                                              short[] result,
                                              FitsHistogram hist,
                                              double min,
                                              double max,
                                              double sigma,
                                              int scaleMethod,
                                              int colortype,
                                              int datatype)
                                       throws nom.tam.fits.FitsException,
                                              BufferedFitsImage.DataTypeNotSupportedException
Creates a buffered image with color space type gray. This is the most memory efficient method, but it does not behave well under scaling. In particular, scaling to non-integer values brightens points. This behaviour is found with jdk1.4.2 and 1.5.0.6 on linux debian and is probably due to the native filter library. It can be circumvented, though, if the buffered image is promoted to sRGB, resulting in three times the memory consumption, as each point shows up as equal value in the gray lavel.

Throws:
nom.tam.fits.FitsException
BufferedFitsImage.DataTypeNotSupportedException

revision

public static String revision()
Returns:
CVS Revision number.