edu.mines.jtk.mosaic
Class PixelsView

java.lang.Object
  extended by edu.mines.jtk.mosaic.TiledView
      extended by edu.mines.jtk.mosaic.PixelsView

public class PixelsView
extends TiledView

A view of sampled functions f(x1,x2), displayed as a 2-D array of pixels. Function values are converted to pixel colors in two steps. In the first step, these values are converted to unsigned bytes in the range [0,255]. In the second step, those bytes are converted to pixel colors.

The first step is a mapping from function values to unsigned byte values. This mapping is linear, except for clipping, which ensures that no byte value lies outside the range [0,255]. The linear mapping is defined by two clip values, clipMin and clipMax. The minimum clip value clipMin corresponds to byte value 0, and the maximum clip value clipMax corresponds to byte value 255. Sample values less than clipMin are mapped to 0; sample values greater than clipMax are mapped to 255.

Byte values are computed for every pixel displayed by this view. Because the view typically contains more pixels than samples, this first mapping often requires interpolation between sampled values of functions f(x1,x2). Either linear or nearest-neighbor interpolation may be specified for this first step.

The second step depends on the number (one, three, or four) of sampled functions specified. For one function, the byte values are indices for a table of 256 colors (a color map) in a specified index color model. See ColorMap for more details.

For three (or four) sampled functions, the byte values are interpreted directly as color components red, green, and blue (and alpha). In this case, any indexed color model specified is not used. The number of color components equals the number of sampled functions specified.

Version:
2005.09.27
Author:
Dave Hale, Colorado School of Mines

Nested Class Summary
static class PixelsView.Interpolation
          Method used to interpolate pixels between samples of f(x1,x2).
static class PixelsView.Orientation
          Orientation of sample axes x1 and x2.
 
Constructor Summary
PixelsView(float[][] f)
          Constructs a pixels view of the specified sampled function f(x1,x2).
PixelsView(float[][][] f)
          Constructs a pixels view of the specified sampled functions f(x1,x2).
PixelsView(Sampling s1, Sampling s2, float[][] f)
          Constructs a pixels view of the specified sampled function f(x1,x2).
PixelsView(Sampling s1, Sampling s2, float[][][] f)
          Constructs a pixels view of the specified sampled functions f(x1,x2).
 
Method Summary
 void addColorMapListener(ColorMapListener cml)
          Adds the specified color map listener.
 float getClipMax()
          Gets the maximum clip value.
 float getClipMax(int ic)
          Gets the maximum clip value for the specified color component.
 float getClipMin()
          Gets the minimum clip value.
 float getClipMin(int ic)
          Gets the minimum clip value for the specified color component.
 ColorMap getColorMap()
          Gets the color map for this view.
 java.awt.image.IndexColorModel getColorModel()
          Gets the index color model for this view.
 PixelsView.Interpolation getInterpolation()
          Gets the method for interpolation between samples.
 PixelsView.Orientation getOrientation()
          Gets the orientation of sample axes.
 float getPercentileMax()
          Gets the maximum percentile.
 float getPercentileMax(int ic)
          Gets the maximum percentile for the specified color component.
 float getPercentileMin()
          Gets the minimum percentile.
 float getPercentileMin(int ic)
          Gets the minimum percentile for the specified color component.
 void paint(java.awt.Graphics2D g2d)
          Paints this tiled view.
 void removeColorMapListener(ColorMapListener cml)
          Removes the specified color map listener.
 void set(float[][] f)
          Sets the sampled function f(x1,x2) for this view.
 void set(float[][][] f)
          Sets the sampled functions f(x1,x2) for this view.
 void set(Sampling s1, Sampling s2, float[][] f)
          Sets the sampled function f(x1,x2) for this view.
 void set(Sampling s1, Sampling s2, float[][][] f)
          Sets the sampled functions f(x1,x2) for this view.
 void setClips(float clipMin, float clipMax)
          Sets the clips for this view.
 void setClips(int ic, float clipMin, float clipMax)
          Sets the clips for the specified color component.
 void setColorModel(java.awt.image.IndexColorModel colorModel)
          Sets the index color model for this view.
 void setInterpolation(PixelsView.Interpolation interpolation)
          Sets the method for interpolation between samples.
 void setOrientation(PixelsView.Orientation orientation)
          Sets the orientation of sample axes.
 void setPercentiles(float percMin, float percMax)
          Sets the percentiles used to compute clips for this view.
 void setPercentiles(int ic, float percMin, float percMax)
          Sets the percentiles for the specified color component.
 
Methods inherited from class edu.mines.jtk.mosaic.TiledView
getBestHorizontalProjector, getBestVerticalProjector, getHorizontalProjector, getLineWidth, getTile, getTranscaler, getVerticalProjector, repaint, setBestProjectors
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PixelsView

public PixelsView(float[][] f)
Constructs a pixels view of the specified sampled function f(x1,x2). Assumes zero first sample values and unit sampling intervals. Function values are converted to colors using an index color model.

Parameters:
f - array[n2][n1] of sampled function values f(x1,x2).

PixelsView

public PixelsView(float[][][] f)
Constructs a pixels view of the specified sampled functions f(x1,x2). Assumes zero first sample values and unit sampling intervals. Function values are converted to colors using a direct color model.

Parameters:
f - array[nc][n2][n1] of sampled function values f(x1,x2), where nc is the number (three or four) of color components.

PixelsView

public PixelsView(Sampling s1,
                  Sampling s2,
                  float[][] f)
Constructs a pixels view of the specified sampled function f(x1,x2). Function values are converted to colors using an index color model.

Parameters:
s1 - the sampling of the variable x1; must be uniform.
s2 - the sampling of the variable x2; must be uniform.
f - array[n2][n1] of sampled function values f(x1,x2).

PixelsView

public PixelsView(Sampling s1,
                  Sampling s2,
                  float[][][] f)
Constructs a pixels view of the specified sampled functions f(x1,x2). Assumes zero first sample values and unit sampling intervals. Function values are converted to colors using a direct color model.

Parameters:
s1 - the sampling of the variable x1; must be uniform.
s2 - the sampling of the variable x2; must be uniform.
f - array[nc][n2][n1] of sampled function values f(x1,x2), where nc is the number (three or four) of color components.
Method Detail

set

public void set(float[][] f)
Sets the sampled function f(x1,x2) for this view. If compatible samplings for x1 and x2 have already been specified, then this method uses them. Otherwise, this method assumes zero first sample values and unit sampling intervals. Function values are converted to colors using an index color model.

Parameters:
f - array[n2][n1] of sampled function values f(x1,x2).

set

public void set(float[][][] f)
Sets the sampled functions f(x1,x2) for this view. If compatible samplings for x1 and x2 have already been specified, then this method uses them. Otherwise, this method assumes zero first sample values and unit sampling intervals. Function values are converted to colors using a direct color model.

Parameters:
f - array[nc][n2][n1] of sampled function values f(x1,x2), where nc is the number (three or four) of color components.

set

public void set(Sampling s1,
                Sampling s2,
                float[][] f)
Sets the sampled function f(x1,x2) for this view. Function values are converted to colors using an index color model.

Parameters:
s1 - the sampling of the variable x1; must be uniform.
s2 - the sampling of the variable x2; must be uniform.
f - array[n2][n1] of sampled function values f(x1,x2).

set

public void set(Sampling s1,
                Sampling s2,
                float[][][] f)
Sets the sampled functions f(x1,x2) for this view. Function values are converted to colors using a direct color model.

Parameters:
s1 - the sampling of the variable x1; must be uniform.
s2 - the sampling of the variable x2; must be uniform.
f - array[nc][n2][n1] of sampled function values f(x1,x2), where nc is the number (three or four) of color components. This number must equal that when this view was constructed.

setOrientation

public void setOrientation(PixelsView.Orientation orientation)
Sets the orientation of sample axes.

Parameters:
orientation - the orientation.

getOrientation

public PixelsView.Orientation getOrientation()
Gets the orientation of sample axes.

Returns:
the orientation.

setInterpolation

public void setInterpolation(PixelsView.Interpolation interpolation)
Sets the method for interpolation between samples.

Parameters:
interpolation - the interpolation method.

getInterpolation

public PixelsView.Interpolation getInterpolation()
Gets the method for interpolation between samples.

Returns:
the interpolation method.

getColorMap

public ColorMap getColorMap()
Gets the color map for this view.

Returns:
the color map.

setColorModel

public void setColorModel(java.awt.image.IndexColorModel colorModel)
Sets the index color model for this view. For three or four color components, a direct color model is used instead of this index color model. The default color model is a black-to-white gray model.

Parameters:
colorModel - the index color model.

getColorModel

public java.awt.image.IndexColorModel getColorModel()
Gets the index color model for this view.

Returns:
the index color model; null, if a direct color model is being used (for multiple color components) instead of an index color model.

setClips

public void setClips(float clipMin,
                     float clipMax)
Sets the clips for this view. A pixels view maps values of the sampled function f(x1,x2) to bytes, which are then used as indices into a specified color model. This mapping from sample values to byte indices is linear, and depends on only these two clip values. The minimum clip value corresponds to byte index 0, and the maximum clip value corresponds to byte index 255. Sample values outside of the range (clipMin,clipMax) are clipped to lie inside this range.

Calling this method disables the computation of clips from percentiles. Any clip values computed or specified previously will be forgotten.

If multiple color components, sets clips for all components.

Parameters:
clipMin - the sample value corresponding to color model index 0.
clipMax - the sample value corresponding to color model index 255.

getClipMin

public float getClipMin()
Gets the minimum clip value. If multiple color components, gets the minimum clip value for only the first color component.

Returns:
the minimum clip value.

getClipMax

public float getClipMax()
Gets the maximum clip value. If multiple color components, gets the maximum clip value for only the first color component.

Returns:
the maximum clip value.

setPercentiles

public void setPercentiles(float percMin,
                           float percMax)
Sets the percentiles used to compute clips for this view. The default percentiles are 0 and 100, which correspond to the minimum and maximum values of the sampled function f(x1,x2).

Calling this method enables the computation of clips from percentiles. Any clip values specified or computed previously will be forgotten.

If multiple color components, sets percentiles for all components.

Parameters:
percMin - the percentile corresponding to clipMin.
percMax - the percentile corresponding to clipMax.

getPercentileMin

public float getPercentileMin()
Gets the minimum percentile. If multiple color components, gets the minimum percentile for only the first color component.

Returns:
the minimum percentile.

getPercentileMax

public float getPercentileMax()
Gets the maximum percentile. If multiple color components, gets the maximum percentile for only the first color component.

Returns:
the maximum percentile.

setClips

public void setClips(int ic,
                     float clipMin,
                     float clipMax)
Sets the clips for the specified color component.

Parameters:
ic - the index (0, 1, 2, or 3) of the color component.
clipMin - the sample value corresponding to byte value 0.
clipMax - the sample value corresponding to byte value 255.

getClipMin

public float getClipMin(int ic)
Gets the minimum clip value for the specified color component.

Parameters:
ic - the index (0, 1, 2, or 3) of the color component.
Returns:
the minimum clip value.

getClipMax

public float getClipMax(int ic)
Gets the maximum clip value for the specified color component.

Parameters:
ic - the index (0, 1, 2, or 3) of the color component.
Returns:
the maximum clip value.

setPercentiles

public void setPercentiles(int ic,
                           float percMin,
                           float percMax)
Sets the percentiles for the specified color component.

Parameters:
ic - the index (0, 1, 2, or 3) of the color component.
percMin - the percentile corresponding to clipMin.
percMax - the percentile corresponding to clipMax.

getPercentileMin

public float getPercentileMin(int ic)
Gets the minimum percentile for the specified color component.

Parameters:
ic - the index (0, 1, 2, or 3) of the color component.
Returns:
the minimum percentile.

getPercentileMax

public float getPercentileMax(int ic)
Gets the maximum percentile for the specified color component.

Parameters:
ic - the index (0, 1, 2, or 3) of the color component.
Returns:
the maximum percentile.

addColorMapListener

public void addColorMapListener(ColorMapListener cml)
Adds the specified color map listener.

Parameters:
cml - the listener.

removeColorMapListener

public void removeColorMapListener(ColorMapListener cml)
Removes the specified color map listener.

Parameters:
cml - the listener.

paint

public void paint(java.awt.Graphics2D g2d)
Description copied from class: TiledView
Paints this tiled view. This method is implemented by classes that extend this abstract base class. Implementations may modify the specified graphics context freely. Such modifications will not affect the paintings of other tiled views in the same tile or mosaic.

Tiled views should not replace (set) entirely the transform in the specified graphics context. This transform may already have been set by the tile or its mosaic. Therefore, tiled views should modify this transform only by specifying additional scaling, translation, etc.

Specified by:
paint in class TiledView
Parameters:
g2d - the graphics context in which to paint.