org.jscience.io.fits
Class ImageDigitizer

java.lang.Object
  extended by org.jscience.io.fits.ImageDigitizer
All Implemented Interfaces:
java.awt.image.ImageProducer, RealImageConsumer

public class ImageDigitizer
extends java.lang.Object
implements RealImageConsumer, java.awt.image.ImageProducer

**************************************************************************** This class converts a stream of double-valued pixels from a RealImageProducer into a stream of integer pixels. This class implements the Java ImageProducer interface, so it can be used to create a Java Image.

The output image will first be gamma corrected, meaning the pixel values are raised to the power of 1/γ, where γ is set by setGamma(double). Then it is scaled so that the smallest real pixel value corresponds to the smallest ingeger or byte value and the largest real value corresponds to the largest ingeter or byte value.

Since digitization can take time, you can register ChangeListeners to monitor the progress of the digitization. *****************************************************************************


Constructor Summary
ImageDigitizer(RealImageProducer source, java.awt.image.ColorModel color)
          *********************************************************************** Create an ImageDigitizer using a given color model and which will digitize the data from a given source.
 
Method Summary
 void abortSend()
          *********************************************************************** abort the image we are sending if we are actually sending an image ************************************************************************
 void addChangeListener(javax.swing.event.ChangeListener l)
          *********************************************************************** add a change listener to receive change events when significant progress has been made digitizing the image ************************************************************************
 void addConsumer(java.awt.image.ImageConsumer ic)
          *********************************************************************** register an integer image consumer
 byte digitizeToByte(double pixel)
          *********************************************************************** this is where the actual digitization happens for byte color models ************************************************************************
 int digitizeToInt(double pixel)
          *********************************************************************** this is where the actual digitization happens for int color models ************************************************************************
 java.awt.image.ColorModel getColorModel()
          *********************************************************************** get the color model for the digitized pixels ************************************************************************
 double getProgress()
          *********************************************************************** returns the fraction of pixels which have been processed ************************************************************************
 void imageComplete(int status)
          *********************************************************************** pass along the image complete message to the integer image
 boolean isConsumer(java.awt.image.ImageConsumer ic)
          *********************************************************************** returns true if the given integer consumer is registered
 void removeChangeListener(javax.swing.event.ChangeListener l)
          *********************************************************************** remove a change listener ************************************************************************
 void removeConsumer(java.awt.image.ImageConsumer ic)
          *********************************************************************** unregister the given integer consumer
 void requestTopDownLeftRightResend(java.awt.image.ImageConsumer ic)
          *********************************************************************** passes the request up to the RealImageProducer ************************************************************************
 double scalePixel(double pixel)
          *********************************************************************** return a pixel value scaled so that min -> 0 and max -> 1 and with gamma correction applied
 void setChangeIncrement(double increment)
          *********************************************************************** set the interval at which change events are fired in terms of fraction of completion ************************************************************************
 void setColorModel(java.awt.image.ColorModel color)
          *********************************************************************** set the color model for the digitized pixels.
 void setDimensions(int width, int height)
          *********************************************************************** pass this information along to the integer image stream
 void setGamma(double gamma)
          *********************************************************************** set the gamma correction factor to used in the digitization.
 void setHints(int hintflags)
          *********************************************************************** pass this information along to the integer image stream
 void setImageSource(RealImageProducer source)
          *********************************************************************** set the RealImageProducer source for the digitizer.
 void setMinMax(double min, double max)
          *********************************************************************** The RealImageProducer calls this method to indicate the pixel limits
 void setNaNvalue(byte value)
          *********************************************************************** set the digitized byte pixel value to use for NaN pixels ************************************************************************
 void setNaNvalue(int value)
          *********************************************************************** set the digitized int pixel value to use for NaN pixels ************************************************************************
 void setPixels(int x, int y, int w, int h, double[] pixels, int offset, int scansize)
          *********************************************************************** the RealImageProducer calls this method to deliver a set of pixels.
 void startProduction(java.awt.image.ImageConsumer ic)
          *********************************************************************** Begin producing pixels for the integer consumers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageDigitizer

public ImageDigitizer(RealImageProducer source,
                      java.awt.image.ColorModel color)
*********************************************************************** Create an ImageDigitizer using a given color model and which will digitize the data from a given source.

Parameters:
source - the source of double valued pixel data.
color - The color model to use in the digitized image. ************************************************************************
Method Detail

setImageSource

public void setImageSource(RealImageProducer source)
*********************************************************************** set the RealImageProducer source for the digitizer. This can be used to change the source after the digitizer has been created. ************************************************************************


setNaNvalue

public void setNaNvalue(int value)
*********************************************************************** set the digitized int pixel value to use for NaN pixels ************************************************************************


setNaNvalue

public void setNaNvalue(byte value)
*********************************************************************** set the digitized byte pixel value to use for NaN pixels ************************************************************************


setColorModel

public void setColorModel(java.awt.image.ColorModel color)
*********************************************************************** set the color model for the digitized pixels. This can be used to change the color model after creating the digitizer. ************************************************************************


getColorModel

public java.awt.image.ColorModel getColorModel()
*********************************************************************** get the color model for the digitized pixels ************************************************************************


setGamma

public void setGamma(double gamma)
*********************************************************************** set the gamma correction factor to used in the digitization. where digitized is proportional to real^1./gamma ************************************************************************


addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener l)
*********************************************************************** add a change listener to receive change events when significant progress has been made digitizing the image ************************************************************************


removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener l)
*********************************************************************** remove a change listener ************************************************************************


setChangeIncrement

public void setChangeIncrement(double increment)
*********************************************************************** set the interval at which change events are fired in terms of fraction of completion ************************************************************************


getProgress

public double getProgress()
*********************************************************************** returns the fraction of pixels which have been processed ************************************************************************


abortSend

public void abortSend()
*********************************************************************** abort the image we are sending if we are actually sending an image ************************************************************************


imageComplete

public void imageComplete(int status)
*********************************************************************** pass along the image complete message to the integer image. ************************************************************************

Specified by:
imageComplete in interface RealImageConsumer
Parameters:
status - DOCUMENT ME!

setDimensions

public void setDimensions(int width,
                          int height)
*********************************************************************** pass this information along to the integer image stream. ************************************************************************

Specified by:
setDimensions in interface RealImageConsumer
Parameters:
width - DOCUMENT ME!
height - DOCUMENT ME!

setMinMax

public void setMinMax(double min,
                      double max)
*********************************************************************** The RealImageProducer calls this method to indicate the pixel limits. ************************************************************************

Specified by:
setMinMax in interface RealImageConsumer
Parameters:
min - DOCUMENT ME!
max - DOCUMENT ME!

setHints

public void setHints(int hintflags)
*********************************************************************** pass this information along to the integer image stream. ************************************************************************

Specified by:
setHints in interface RealImageConsumer
Parameters:
hintflags - DOCUMENT ME!

setPixels

public void setPixels(int x,
                      int y,
                      int w,
                      int h,
                      double[] pixels,
                      int offset,
                      int scansize)
*********************************************************************** the RealImageProducer calls this method to deliver a set of pixels. This method scales the pixels and converts them to integers or bytes as appropriate for the color model. ************************************************************************

Specified by:
setPixels in interface RealImageConsumer
Parameters:
x - DOCUMENT ME!
y - DOCUMENT ME!
w - DOCUMENT ME!
h - DOCUMENT ME!
pixels - DOCUMENT ME!
offset - DOCUMENT ME!
scansize - DOCUMENT ME!

scalePixel

public double scalePixel(double pixel)
*********************************************************************** return a pixel value scaled so that min -> 0 and max -> 1 and with gamma correction applied. ************************************************************************


digitizeToByte

public byte digitizeToByte(double pixel)
*********************************************************************** this is where the actual digitization happens for byte color models ************************************************************************


digitizeToInt

public int digitizeToInt(double pixel)
*********************************************************************** this is where the actual digitization happens for int color models ************************************************************************


addConsumer

public void addConsumer(java.awt.image.ImageConsumer ic)
*********************************************************************** register an integer image consumer. ************************************************************************

Specified by:
addConsumer in interface java.awt.image.ImageProducer

isConsumer

public boolean isConsumer(java.awt.image.ImageConsumer ic)
*********************************************************************** returns true if the given integer consumer is registered. ************************************************************************

Specified by:
isConsumer in interface java.awt.image.ImageProducer

removeConsumer

public void removeConsumer(java.awt.image.ImageConsumer ic)
*********************************************************************** unregister the given integer consumer. ************************************************************************

Specified by:
removeConsumer in interface java.awt.image.ImageProducer

startProduction

public void startProduction(java.awt.image.ImageConsumer ic)
*********************************************************************** Begin producing pixels for the integer consumers. This just calls RealImageProducer.startProduction(RealImageConsumer). ************************************************************************

Specified by:
startProduction in interface java.awt.image.ImageProducer

requestTopDownLeftRightResend

public void requestTopDownLeftRightResend(java.awt.image.ImageConsumer ic)
*********************************************************************** passes the request up to the RealImageProducer ************************************************************************

Specified by:
requestTopDownLeftRightResend in interface java.awt.image.ImageProducer