edu.mines.jtk.util
Class FloatByteMap

java.lang.Object
  extended by edu.mines.jtk.util.FloatByteMap

public class FloatByteMap
extends java.lang.Object

Maps float values to unsigned byte values in the range [0,255]. This mapping is useful in graphics where the bytes are indices or components of colors in color maps.

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

Constructor Summary
FloatByteMap(double percMin, double percMax, float[] f)
          Constructs a map for the specified percentiles and array.
FloatByteMap(double percMin, double percMax, float[][] f)
          Constructs a map for the specified percentiles and array.
FloatByteMap(double percMin, double percMax, float[][][] f)
          Constructs clips for the specified percentiles and array.
FloatByteMap(double percMin, double percMax, Float3 f3)
          Constructs clips for the specified percentiles and array.
FloatByteMap(float[] f)
          Constructs a map for specified values.
FloatByteMap(float[][] f)
          Constructs a map for specified values.
FloatByteMap(float[][][] f)
          Constructs a map for specified values.
FloatByteMap(Float3 f3)
          Constructs a map for specified values.
 
Method Summary
 int getByte(float f)
          Gets the byte value corresponding to the specified float value.
 void getBytes(float[][][] f, byte[] b)
          Gets byte values corresponding to specified float values.
 void getBytes(float[][][] f, byte[][][] b)
          Gets byte values corresponding to specified float values.
 void getBytes(float[][] f, byte[] b)
          Gets byte values corresponding to specified float values.
 void getBytes(float[][] f, byte[][] b)
          Gets byte values corresponding to specified float values.
 void getBytes(float[] f, byte[] b)
          Gets byte values corresponding to specified float values.
 void getBytes(Float3 f3, byte[] b)
          Gets byte values corresponding to specified float values.
 void getBytes(Float3 f3, byte[][][] b)
          Gets byte values corresponding to specified float values.
 float getClipMax()
          Gets the maximum clip value for this mapping.
 float getClipMin()
          Gets the minimum clip value for this mapping.
 float getPercentileMax()
          Gets the maximum percentile.
 float getPercentileMin()
          Gets the minimum percentile.
 void setClips(double clipMin, double clipMax)
          Sets the clips for this mapping.
 void setPercentiles(double percMin, double percMax)
          Sets the percentiles used to compute clips for this mapping.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FloatByteMap

public FloatByteMap(float[] f)
Constructs a map for specified values.

Parameters:
f - array of values; by reference, not by copy.

FloatByteMap

public FloatByteMap(float[][] f)
Constructs a map for specified values.

Parameters:
f - array of values; by reference, not by copy.

FloatByteMap

public FloatByteMap(float[][][] f)
Constructs a map for specified values.

Parameters:
f - array of values; by reference, not by copy.

FloatByteMap

public FloatByteMap(Float3 f3)
Constructs a map for specified values.

Parameters:
f3 - abstract 3-D array of values; by reference, not by copy.

FloatByteMap

public FloatByteMap(double percMin,
                    double percMax,
                    float[] f)
Constructs a map for the specified percentiles and array.

Parameters:
percMin - the percentile corresponding to clipMin.
percMax - the percentile corresponding to clipMax.
f - array of values; by reference, not by copy.

FloatByteMap

public FloatByteMap(double percMin,
                    double percMax,
                    float[][] f)
Constructs a map for the specified percentiles and array.

Parameters:
percMin - the percentile corresponding to clipMin.
percMax - the percentile corresponding to clipMax.
f - array of values; by reference, not by copy.

FloatByteMap

public FloatByteMap(double percMin,
                    double percMax,
                    float[][][] f)
Constructs clips for the specified percentiles and array.

Parameters:
percMin - the percentile corresponding to clipMin.
percMax - the percentile corresponding to clipMax.
f - array of values; by reference, not by copy.

FloatByteMap

public FloatByteMap(double percMin,
                    double percMax,
                    Float3 f3)
Constructs clips for the specified percentiles and array.

Parameters:
percMin - the percentile corresponding to clipMin.
percMax - the percentile corresponding to clipMax.
f3 - abstract 3-D array of values; by reference, not by copy.
Method Detail

getByte

public int getByte(float f)
Gets the byte value corresponding to the specified float value.

Parameters:
f - the float value to be mapped.
Returns:
the unsigned byte value in the range [0,255].

getBytes

public void getBytes(float[] f,
                     byte[] b)
Gets byte values corresponding to specified float values.

Parameters:
f - input array of float values to be mapped.
b - output array of unsigned byte values in the range [0,255].

getBytes

public void getBytes(float[][] f,
                     byte[][] b)
Gets byte values corresponding to specified float values.

Parameters:
f - input array of float values to be mapped.
b - output array of unsigned byte values in the range [0,255].

getBytes

public void getBytes(float[][] f,
                     byte[] b)
Gets byte values corresponding to specified float values.

Parameters:
f - input array of float values to be mapped.
b - output array of unsigned byte values in the range [0,255].

getBytes

public void getBytes(float[][][] f,
                     byte[][][] b)
Gets byte values corresponding to specified float values.

Parameters:
f - input array of float values to be mapped.
b - output array of unsigned byte values in the range [0,255].

getBytes

public void getBytes(float[][][] f,
                     byte[] b)
Gets byte values corresponding to specified float values.

Parameters:
f - input array of float values to be mapped.
b - output array of unsigned byte values in the range [0,255].

getBytes

public void getBytes(Float3 f3,
                     byte[][][] b)
Gets byte values corresponding to specified float values.

Parameters:
f3 - input array of float values to be mapped.
b - output array of unsigned byte values in the range [0,255].

getBytes

public void getBytes(Float3 f3,
                     byte[] b)
Gets byte values corresponding to specified float values.

Parameters:
f3 - input array of float values to be mapped.
b - output array of unsigned byte values in the range [0,255].

setClips

public void setClips(double clipMin,
                     double clipMax)
Sets the clips for this mapping.

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

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

getClipMin

public float getClipMin()
Gets the minimum clip value for this mapping.

Returns:
the minimum clip value.

getClipMax

public float getClipMax()
Gets the maximum clip value for this mapping.

Returns:
the maximum clip value.

setPercentiles

public void setPercentiles(double percMin,
                           double percMax)
Sets the percentiles used to compute clips for this mapping. The default percentiles are 0 and 100, which correspond to the minimum and maximum array values.

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

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

getPercentileMin

public float getPercentileMin()
Gets the minimum percentile.

Returns:
the minimum percentile.

getPercentileMax

public float getPercentileMax()
Gets the maximum percentile.

Returns:
the maximum percentile.