Class ModelLUT

All Implemented Interfaces:
Serializable, Cloneable

public class ModelLUT extends ModelStorageBase
Model of a Lookup Table (LUT). At present, one can construct 10 different LUTs: GRAY, SPECTRUM, HOTMETAL, COOLHOT, SKIN, STRIPED, RED, GREEN, BLUE, GRAY_BR, and BONE. This class allows the programmer to specify the number of colors for the LUT. The LUT extents should be 4 x 256 or problems may arise with the differing colormaps (This class can be extended to handle arbitrary size LUTs but 256 is almost universal). There are 256 locations with alpha, red, green, and blue values as floats in order to store both RGB or HSI or etc. The LUTs are calculated from the corresponding transfer functions for each of a, r, g, and b.
Version:
1.0
Author:
Matthew J. McAuliffe, Ph.D.
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Use serialVersionUID for interoperability.
      See Also:
    • GRAY

      public static final int GRAY
      Sets up the transfer function colors to be gray.
      See Also:
    • SPECTRUM

      public static final int SPECTRUM
      Sets up the transfer function colors to be colours of .
      See Also:
    • HOTMETAL

      public static final int HOTMETAL
      Sets up the transfer function colors to be hotmetal.
      See Also:
    • COOLHOT

      public static final int COOLHOT
      Sets up the transfer function colors to be cool-hot.
      See Also:
    • SKIN

      public static final int SKIN
      Sets up the transfer function colors to be skin-colors.
      See Also:
    • STRIPED

      public static final int STRIPED
      Sets up the transfer function colors to be striped.
      See Also:
    • RED

      public static final int RED
      Sets up the transfer function colors to be monochrome-red.
      See Also:
    • GREEN

      public static final int GREEN
      Sets up the transfer function colors to be monochrome-green.
      See Also:
    • BLUE

      public static final int BLUE
      Sets up the transfer function colors to be monochrome-blue.
      See Also:
    • GRAY_BR

      public static final int GRAY_BR
      Sets up the transfer function colors to be gray, with blue in the first location, red in the last location.
      See Also:
    • BONE

      public static final int BONE
      Sets up the transfer function to be yellow-ish orange which is supposed to make bones look good.
      See Also:
    • BlackBody

      public static final int BlackBody
      Customized LUTs
      See Also:
    • Cardiac

      public static final int Cardiac
      See Also:
    • Flow

      public static final int Flow
      See Also:
    • GEcolor

      public static final int GEcolor
      See Also:
    • GrayRainbow

      public static final int GrayRainbow
      See Also:
    • HotGreen

      public static final int HotGreen
      See Also:
    • HotIron

      public static final int HotIron
      See Also:
    • HotMetal

      public static final int HotMetal
      See Also:
    • Hue1

      public static final int Hue1
      See Also:
    • Hue2

      public static final int Hue2
      See Also:
    • ired

      public static final int ired
      See Also:
    • NIH

      public static final int NIH
      See Also:
    • Rainbow

      public static final int Rainbow
      See Also:
    • Rainbow2

      public static final int Rainbow2
      See Also:
    • Rainbow3

      public static final int Rainbow3
      See Also:
    • Ratio

      public static final int Ratio
      See Also:
    • Spectrum

      public static final int Spectrum
      See Also:
    • Stern

      public static final int Stern
      See Also:
    • UCLA

      public static final int UCLA
      See Also:
    • VR_Bones

      public static final int VR_Bones
      See Also:
    • VR_Muscles_Bones

      public static final int VR_Muscles_Bones
      See Also:
    • VR_Red_Vessels

      public static final int VR_Red_Vessels
      See Also:
    • alphaLine

      private TransferFunction alphaLine
      Fucntion that attenuates image values.
    • blueLine

      private TransferFunction blueLine
      Function that maps the blue function of the LUT.
    • greenLine

      private TransferFunction greenLine
      Function that maps the green function of the LUT.
    • indexedLUT

      private int[] indexedLUT
      Special int array where the LUT is packed with alpha in the most significant byte of the int, followed red, green, and blue.
    • nColors

      private int nColors
      Number of colors in the LUT.
    • redLine

      private TransferFunction redLine
      Function that maps the red function of the LUT.
    • remappedLUT

      private int[] remappedLUT
      DOCUMENT ME!
    • transferLine

      private TransferFunction transferLine
      Function that maps image values into the LUT. The x coord. ranges [image.min, image.max];
    • type

      private int type
      DOCUMENT ME!
    • x

      private float[] x
      The X coordinates of the transfer functions.
    • customLUTsLocation

      public static final String customLUTsLocation
      Opens and returns a buffered reader for a given custom LUT name.
      See Also:
  • Constructor Details

    • ModelLUT

      public ModelLUT()
      Default Constructor.
    • ModelLUT

      public ModelLUT(int _type, int _nColors, int[] dimExtents)
      Constructor.
      Parameters:
      _type - indicates type of lut (ie. GRAY, SPECTRUM ...)
      _nColors - number of colors defined in LUT
      dimExtents - array indicating LUT extent in each dimension (e.g. 4x256)
  • Method Details

    • finalize

      public void finalize()
      Description copied from class: ModelStorageBase
      Calls disposeLocal of this class to ensure this class nulls the references to global class variables so that memory will be recovered.
      Overrides:
      finalize in class ModelStorageBase
    • buildTDistLUT

      public static ModelLUT buildTDistLUT(int dof, double sig, ModelImage image)
      Build LUT consisting of a student t-distribution at the specified level os significance for the given degrees of freedom.
      Parameters:
      dof - degrees of freedom
      sig - level of significance
      image -
      Returns:
    • exportIndexedLUT

      public final int[] exportIndexedLUT()
      This is a method to export a special int array where the alpha is stored in the most significant byte, then red, green and blue. Note that the transfer function has been applied to it.
      Returns:
      remappedLUT location where indexLUT will be exported to
    • exportIndexedLUTMin

      public static void exportIndexedLUTMin(ModelLUT kLut, byte[] remappedLUTMin)
      Parameters:
      kLUT - model lut
      kTransferLine - transfer function
      iHeight - lut height
      iTable -
    • exportIndexedLUTMin

      public static void exportIndexedLUTMin(ModelLUT kLut, byte[] remappedLUTMin, int index)
    • exportIndexedLUTMin

      public static void exportIndexedLUTMin(ModelRGB kRGBT, byte[] remappedLUTMin)
    • exportIndexedLUT

      public final int exportIndexedLUT(int[] arrayLUT)
      This is a method to export a special int array where the alpha is stored in the most significant byte, then red, green and blue. Without the transfer function applied to the LUT
      Parameters:
      arrayLUT - location where indexLUT will be exported.
      Returns:
      int 0 indictes error, and 1 indicates successful completion
    • exportRGB_LUT

      public final float[][] exportRGB_LUT(boolean applyAlpha)
      This is a method to export a 2D float array of the LUT. This method is used by the ViewJComponent show methods to blend between two images.
      Parameters:
      applyAlpha - flag indicating if the LUT's alpha values should be applied
      Returns:
      float returns the RGB LUT a 2D array
    • getAlphaFunction

      public TransferFunction getAlphaFunction()
      Accessor that returns the alpha transfer function.
      Returns:
      the transfer function that describes how to map the alpha values
    • getBlueFunction

      public TransferFunction getBlueFunction()
      Accessor that returns the blue transfer function.
      Returns:
      the transfer function that describes how to map the blue values
    • getColor

      public Color getColor(int index)
      Gets a specific index of the LUT.
      Parameters:
      index - index of the LUT, normally 0-255
      Returns:
      LUTcolor color at index
    • getGreenFunction

      public TransferFunction getGreenFunction()
      Accessor that returns the green transfer function.
      Returns:
      the transfer function that describes how to map the green values
    • getLUTType

      public int getLUTType()
      Accessor to get LUT type.
      Returns:
      LUT type
    • getRedFunction

      public TransferFunction getRedFunction()
      Accessor that returns the red transfer function.
      Returns:
      the transfer function that describes how to map the red values
    • getTransferFunction

      public TransferFunction getTransferFunction()
      Accessor that returns the transfer function.
      Returns:
      the transfer function that describes how to remap the image intensities into display values from the LUT.
    • invertLUT

      public void invertLUT()
      Inverts the LUT using the values stored in the band arrays and not the transfer functions.
    • makeBlueTransferFunctions

      public void makeBlueTransferFunctions()
      Creates the R, G, and B transfer functions to produce a blue scale LUT.
    • makeBoneTransferFunctions

      public void makeBoneTransferFunctions()
      Creates the R, G, and B transfer functions to produce a bone scale LUT.
    • makeCoolHotTransferFunctions

      public void makeCoolHotTransferFunctions()
      Creates the R, G, and B transfer functions to produce a "Cool hot" scale LUT. (blue -> pink -> red -> orange -> yellow -> white)
    • makeCTThighTransferFunctions

      public void makeCTThighTransferFunctions()
      Makes a LUT specifically for viewing CT thigh images
    • makeGrayBRTransferFunctions

      public void makeGrayBRTransferFunctions()
      Creates the R, G, and B transfer functions to produce a gray scale LUT.
    • makeGrayTransferFunctions

      public void makeGrayTransferFunctions()
      Creates the R, G, and B transfer functions to produce a gray scale LUT.
    • makeGreenTransferFunctions

      public void makeGreenTransferFunctions()
      Creates the R, G, and B transfer functions to produce a green scale LUT.
    • makeHotMetalTransferFunctions

      public void makeHotMetalTransferFunctions()
      Creates the R, G, and B transfer functions to produce a spectrum scale LUT. (black -> red -> orange -> yellow -> white)
    • makeIndexedLUT

      public void makeIndexedLUT(int[] opacityArray)
      Special LUT to be used to display java image. Assumes RGB values that range between (0 and 255) are stored in the LUT;
      Parameters:
      opacityArray - DOCUMENT ME!
    • makeLUT

      public void makeLUT(int _nColors)
      This method uses the A, R, G, B transfer functions to build the desired LUT.
      Parameters:
      _nColors - indicates the number of colors to used in the LUT.
    • makeRedTransferFunctions

      public void makeRedTransferFunctions()
      Creates the R, G, and B transfer functions to produce a red scale LUT.
    • makeSkinTransferFunctions

      public void makeSkinTransferFunctions()
      Creates the R, G, and B transfer functions to produce a skin scale LUT. (blue -> pink -> red -> orange -> yellow -> white)
    • makeSpectrumTransferFunctions

      public void makeSpectrumTransferFunctions()
      Creates the R, G, and B transfer functions to produce a spectrum scale LUT. (blue -> light blue -> green -> yellow -> orange -> red)
    • makeStripedLUT

      public void makeStripedLUT()
      makeStripedLUT -
    • makeCustomizedLUT

      public void makeCustomizedLUT(String name)
      makeVR with customized LUT
    • oneToZeroLUTAdjust

      public void oneToZeroLUTAdjust()
      The purpose of this method is to adjust the zero index of the LUT from (1, 1, 1) to (0, 0, 0) The reason is so image A and image B are not blended throughout by default.
    • resetAlphaLine

      public void resetAlphaLine()
      Resets the alpha function to be linear.
    • resetTransferLine

      public void resetTransferLine(float min, float max)
      Resets the transfer function to be linear.
      Parameters:
      min - DOCUMENT ME!
      max - DOCUMENT ME!
    • resetTransferLine

      public void resetTransferLine(float min, float imgMin, float max, float imgMax)
      Resets the transfer function to be linear.
      Parameters:
      min - float the minimum for the data range of this image type
      imgMin - float the actual minimum data value for the image
      max - float the maximum for the data range of this image type
      imgMax - float the actual maximum data value for the image
    • setColor

      public void setColor(int index, Color LUTcolor)
      Sets a specific index of the LUT with the given color.
      Parameters:
      index - index of the LUT, normally 0-255
      LUTcolor - color to be placed at the LUT
    • setColor

      public void setColor(int index, int alpha, int red, int green, int blue)
      Sets a specific index of the LUT with the given color and updates the compressed LUT.
      Parameters:
      index - int index of the LUT
      alpha - int 0-255 alpha
      red - int 0-255 red
      green - int 0-255 green
      blue - int 0-255 blue
    • setTransferFunction

      public void setTransferFunction(TransferFunction txFunction)
      Sets the LUTs transfer function.
      Parameters:
      txFunction - DOCUMENT ME!
    • toString

      public String toString()
      displays the LUT colours and alpha values in hex.
      Overrides:
      toString in class Object
      Returns:
      DOCUMENT ME!
    • toString

      public String toString(boolean displayInHex, boolean displayAlphaValues)
      Presents the Lookuptable by.
      Parameters:
      displayInHex - DOCUMENT ME!
      displayAlphaValues - DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • zeroToOneLUTAdjust

      public void zeroToOneLUTAdjust()
      The purpose of this method is to adjust the zero index of the LUT from (0, 0, 0) to (1, 1, 1) The reason is so image A and image B are blended throughout by default.
    • calcBand

      private void calcBand(TransferFunction function, float[] band)
      Calculates the color band (i.e. red, green, blue) for the LUT using the the corresponding transfer function
      Parameters:
      function - the band's transfer function
      band - storage location after conversion from transfer function to the band
    • getIndexedLUT

      public int[] getIndexedLUT()
    • openLUTFile

      public static final BufferedReader openLUTFile(String lutName) throws IOException
      Throws:
      IOException