jsky.image
Class ImageLookup

java.lang.Object
  extended by jsky.image.ImageLookup

public class ImageLookup
extends java.lang.Object

Implements various image scaling operations that reduce the source image data to byte range. The source image data is first converted to ushort range, if necessary, and then a lookup table is used to convert to byte range, based on the algorithm chosen.

Version:
$Revision: 1.1 $
Author:
Allan Brighton

Field Summary
protected  int dataType
          data type of the image
static int HIST_EQ
          Constant to pass to the scale method for histogram equalization scaling
static int LINEAR_SCALE
          Constant to pass to the scale method for linear scaling
static int LOG_SCALE
          Constant to pass to the scale method for logarithmic scaling
protected static int LOOKUP_MAX
          maximum image value allowed
protected static int LOOKUP_MIN
          minimum image value allowed
protected static int LOOKUP_SIZE
          size of a lookup table for full short range
protected  byte[] lookupArray
          array used by lookup table
protected  int lookupOffset
          lookup table offset (subtract from image value before lookup)
protected  int lookupSize
          size of the lookup table
protected  javax.media.jai.LookupTableJAI lookupTable
          use to convert short data to byte using the selected algorithm
protected static int MAX_COLOR
          maximum color value used in lookup table
protected static int MIN_COLOR
          minimum color value used in lookup table
protected static int NCOLORS
          assume 256 colors in the final image
protected  int scaledHighCut
          high cut value scaled to ushort range
protected  int scaledLowCut
          low cut value scaled to ushort range
static int SQRT_SCALE
          Constant to pass to the scale method for square root scaling
 
Constructor Summary
ImageLookup()
          default constructor
 
Method Summary
protected  int fillLookupTable(int imageVal, int imageLim, int pixVal)
          Set the values in the lookup table from imageVal to imageLim to the given pixel value return the new imageVal index.
 javax.media.jai.LookupTableJAI getLookupTable()
          Return the generated lookup table
 javax.media.jai.PlanarImage histEqScale(javax.media.jai.PlanarImage im, double lowCut, double highCut, javax.media.jai.ROI roi, ImageHistogram imageHistogram)
          Install a lookup table to perform a histogram equalization color scale operation on the image using the given cut levels and ROI and return the resulting image.
 javax.media.jai.PlanarImage linearScale(javax.media.jai.PlanarImage im, double lowCut, double highCut)
          Install a lookup table to perform a linear scale operation on the image using the given cut levels and return the resulting image.
 javax.media.jai.PlanarImage logScale(javax.media.jai.PlanarImage im, double lowCut, double highCut)
          Install a lookup table to perform a logarithmic scale operation on the image using the given cut levels and return the resulting image.
protected  javax.media.jai.PlanarImage makeLookupTable(javax.media.jai.PlanarImage im, double lowCut, double highCut)
          Create an empty lookup table for the given image and scale the image to unsigned short range, if necessary, so that we can use a lookup table of at most 65536 bytes.
 javax.media.jai.PlanarImage scale(javax.media.jai.PlanarImage im, int scaleAlgorithm, double lowCut, double highCut)
          Install a lookup table to perform a color scale operation on the image using the given cut levels and return the resulting image.
 javax.media.jai.PlanarImage scale(javax.media.jai.PlanarImage im, int scaleAlgorithm, double lowCut, double highCut, javax.media.jai.ROI roi, ImageHistogram imageHistogram)
          Install a lookup table to perform a color scale operation on the image using the given cut levels and return the resulting image.
protected  javax.media.jai.PlanarImage scaleToShortRange(javax.media.jai.PlanarImage im, double lowCut, double highCut)
          Scale the given image to short range, if needed, and return the new image.
 javax.media.jai.PlanarImage sqrtScale(javax.media.jai.PlanarImage im, double lowCut, double highCut)
          Install a lookup table to perform a sqare root scale operation on the image using the given cut levels and return the resulting image.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NCOLORS

protected static final int NCOLORS
assume 256 colors in the final image

See Also:
Constant Field Values

MIN_COLOR

protected static final int MIN_COLOR
minimum color value used in lookup table

See Also:
Constant Field Values

MAX_COLOR

protected static final int MAX_COLOR
maximum color value used in lookup table

See Also:
Constant Field Values

LOOKUP_SIZE

protected static final int LOOKUP_SIZE
size of a lookup table for full short range

See Also:
Constant Field Values

LOOKUP_MIN

protected static final int LOOKUP_MIN
minimum image value allowed

See Also:
Constant Field Values

LOOKUP_MAX

protected static final int LOOKUP_MAX
maximum image value allowed

See Also:
Constant Field Values

LINEAR_SCALE

public static final int LINEAR_SCALE
Constant to pass to the scale method for linear scaling

See Also:
Constant Field Values

SQRT_SCALE

public static final int SQRT_SCALE
Constant to pass to the scale method for square root scaling

See Also:
Constant Field Values

LOG_SCALE

public static final int LOG_SCALE
Constant to pass to the scale method for logarithmic scaling

See Also:
Constant Field Values

HIST_EQ

public static final int HIST_EQ
Constant to pass to the scale method for histogram equalization scaling

See Also:
Constant Field Values

lookupTable

protected javax.media.jai.LookupTableJAI lookupTable
use to convert short data to byte using the selected algorithm


lookupArray

protected byte[] lookupArray
array used by lookup table


lookupSize

protected int lookupSize
size of the lookup table


lookupOffset

protected int lookupOffset
lookup table offset (subtract from image value before lookup)


dataType

protected int dataType
data type of the image


scaledLowCut

protected int scaledLowCut
low cut value scaled to ushort range


scaledHighCut

protected int scaledHighCut
high cut value scaled to ushort range

Constructor Detail

ImageLookup

public ImageLookup()
default constructor

Method Detail

getLookupTable

public javax.media.jai.LookupTableJAI getLookupTable()
Return the generated lookup table


scaleToShortRange

protected javax.media.jai.PlanarImage scaleToShortRange(javax.media.jai.PlanarImage im,
                                                        double lowCut,
                                                        double highCut)
Scale the given image to short range, if needed, and return the new image. The given low and high cut values are used to scale int and floating point images to within short range so that a 64K lookup table may be used to scale the image further down to byte range for display, using a chosen algorithm. As a side effect, this method also notes the lookup table size and offsets, which are used to create the lookup table later.


makeLookupTable

protected javax.media.jai.PlanarImage makeLookupTable(javax.media.jai.PlanarImage im,
                                                      double lowCut,
                                                      double highCut)
Create an empty lookup table for the given image and scale the image to unsigned short range, if necessary, so that we can use a lookup table of at most 65536 bytes. Note that we could base the lookup table size on the range of image values, but that would require knowing the exact range, making it impossible to estimate it efficiently. The return image may have been scaled to ushort range, if needed (This is done for int and floating point images).


fillLookupTable

protected int fillLookupTable(int imageVal,
                              int imageLim,
                              int pixVal)
Set the values in the lookup table from imageVal to imageLim to the given pixel value return the new imageVal index.


scale

public javax.media.jai.PlanarImage scale(javax.media.jai.PlanarImage im,
                                         int scaleAlgorithm,
                                         double lowCut,
                                         double highCut)
Install a lookup table to perform a color scale operation on the image using the given cut levels and return the resulting image. Floating point images are first scaled to short range before applying the lookup table. This method only prepares the table and scales floating point images to the correct range if needed. To apply the lookup table to the image, use can use the ImageOps.lookup() method.

Parameters:
im - the input image (for FITS, after applying BZERO and BSCALE, if needed)
scaleAlgorithm - on of the constants defined in this class (LINEAR_SCALE, SQRT_SCALE, LOG_SCALE)
lowCut - ignore image pixel values below this value
highCut - ignore image pixel values above this value

scale

public javax.media.jai.PlanarImage scale(javax.media.jai.PlanarImage im,
                                         int scaleAlgorithm,
                                         double lowCut,
                                         double highCut,
                                         javax.media.jai.ROI roi,
                                         ImageHistogram imageHistogram)
Install a lookup table to perform a color scale operation on the image using the given cut levels and return the resulting image. Floating point images are first scaled to short range before applying the lookup table. This method only prepares the table and scales floating point images to the correct range if needed. To apply the lookup table to the image, use can use the ImageOps.lookup() method.

Parameters:
im - the input image (for FITS, after applying BZERO and BSCALE, if needed)
scaleAlgorithm - on of the constants defined in this class (LINEAR_SCALE, SQRT_SCALE, LOG_SCALE, HIST_EQ)
lowCut - ignore image pixel values below this value
highCut - ignore image pixel values above this value
roi - if set, this describes the region of interest to use for histogram equalization.
imageHistogram - if set, this is used along with the ROI to generate the image histogram

linearScale

public javax.media.jai.PlanarImage linearScale(javax.media.jai.PlanarImage im,
                                               double lowCut,
                                               double highCut)
Install a lookup table to perform a linear scale operation on the image using the given cut levels and return the resulting image. Floating point images are first scaled to short range before applying the lookup table. This method only prepares the table and scales floating point images to the correct range if needed. To apply the lookup table to the image, you can use the ImageOps.lookup() method.


sqrtScale

public javax.media.jai.PlanarImage sqrtScale(javax.media.jai.PlanarImage im,
                                             double lowCut,
                                             double highCut)
Install a lookup table to perform a sqare root scale operation on the image using the given cut levels and return the resulting image. Floating point images are first scaled to short range before applying the lookup table. This method only prepares the table and scales floating point images to the correct range if needed. To apply the lookup table to the image, use can use the ImageOps.lookup() method.


logScale

public javax.media.jai.PlanarImage logScale(javax.media.jai.PlanarImage im,
                                            double lowCut,
                                            double highCut)
Install a lookup table to perform a logarithmic scale operation on the image using the given cut levels and return the resulting image. Floating point images are first scaled to short range before applying the lookup table. This method only prepares the table and scales floating point images to the correct range if needed. To apply the lookup table to the image, use can use the ImageOps.lookup() method.


histEqScale

public javax.media.jai.PlanarImage histEqScale(javax.media.jai.PlanarImage im,
                                               double lowCut,
                                               double highCut,
                                               javax.media.jai.ROI roi,
                                               ImageHistogram imageHistogram)
Install a lookup table to perform a histogram equalization color scale operation on the image using the given cut levels and ROI and return the resulting image. Floating point images are first scaled to short range before applying the lookup table. This method only prepares the table and scales floating point images to the correct range if needed. To apply the lookup table to the image, use can use the ImageOps.lookup() method.

Parameters:
im - the input image (for FITS, after applying BZERO and BSCALE, if needed)
lowCut - ignore image pixel values below this value
highCut - ignore image pixel values above this value
roi - if set, this describes the region of interest to use for histogram equalization.
imageHistogram - if set, this is used along with the ROI to generate the image histogram