Class FileHistoLUT

java.lang.Object
gov.nih.mipav.model.file.FileBase
gov.nih.mipav.model.file.FileHistoLUT

public class FileHistoLUT extends FileBase
HistoLUT reader/writer. This classes incorporates the ability to write/read ModelLUT and ModelRGB information in two ways. The first saves the LUT arrays (not available with ModelRGB), and the second saves the transfer and RGB functions. The LUT transfer Line is saved by default (and likewise opened) when the saveLUT method is called.

NOTE: Reading a LUT does not return a ModelLUT. Rather, it updates the arrays and transfer functions in a provided ModelLUT.

Version:
May 14, 2002
Author:
Lynne M. Pusanik
See Also:
  • Field Details

    • lutTag

      private static final String lutTag
      Tag marking the beginning of a LUT data file.
      See Also:
    • funcTag

      private static final String funcTag
      Tag marking the beginning of a transfer function file.
      See Also:
    • endTag

      private static final String endTag
      Tag marking the end of a LUT or transfer file.
      See Also:
    • fileDir

      private String fileDir
      The file directory containing the data files.
    • funcFileName

      private String funcFileName
      The file name of the transfer function data file.
    • lut

      private ModelLUT lut
      The (grayscale) LUT to save.
    • lutFileName

      private String lutFileName
      The file name of the LUT data file.
    • opacityFunction

      private TransferFunction opacityFunction
      The opacity transfer function, saved if non-null.
    • rgb

      private ModelRGB rgb
      The color image histogram data to save.
    • useLUT

      private boolean useLUT
      Whether to use the LUT or the RGB model.
    • img

      private ModelImage img
      ModelImage to use for reference
  • Constructor Details

    • FileHistoLUT

      public FileHistoLUT(String fileName, String fileDir) throws IOException
      LUT reader/writer constructor.
      Parameters:
      fileName - file name
      fileDir - file directory
      Throws:
      IOException - if there is an error making the files
    • FileHistoLUT

      public FileHistoLUT(String fileName, String fileDir, ModelLUT lut) throws IOException
      LUT reader/writer constructor.
      Parameters:
      fileName - file name
      fileDir - file directory
      lut - the ModelLUT
      Throws:
      IOException - if there is an error making the files, or if lut is null
    • FileHistoLUT

      public FileHistoLUT(String fileName, String fileDir, ModelImage image, ModelLUT lut) throws IOException
      LUT reader/writer constructor.
      Parameters:
      fileName - file name
      fileDir - file directory
      lut - the ModelLUT
      Throws:
      IOException - if there is an error making the files, or if lut is null
    • FileHistoLUT

      public FileHistoLUT(String fileName, String fileDir, ModelImage image, ModelStorageBase lut) throws IOException
      LUT reader/writer constructor.
      Parameters:
      fileName - file name
      fileDir - file directory
      lut - the ModelLUT
      Throws:
      IOException - if there is an error making the files, or if lut is null
    • FileHistoLUT

      public FileHistoLUT(String fileName, String fileDir, ModelRGB rgb) throws IOException
      RGB reader/writer constructor.
      Parameters:
      fileName - file name
      fileDir - file directory
      rgb - the ModelRGB
      Throws:
      IOException - if there is an error making the files, or if rgb is null
    • FileHistoLUT

      public FileHistoLUT(String fileName, String fileDir, ModelImage image, ModelRGB rgb) throws IOException
      RGB reader/writer constructor.
      Parameters:
      fileName - file name
      fileDir - file directory
      rgb - the ModelRGB
      Throws:
      IOException - if there is an error making the files, or if rgb is null
  • Method Details

    • readFunctions

      public void readFunctions() throws IOException
      This method reads the transfer and RGB functions associated with a LUT.
      Throws:
      IOException - if there is an error reading the file
    • readFunctions

      public void readFunctions(ModelLUT lut) throws IOException
      This method reads the transfer for a grayscale image and the RGB functions that define the LUT.
      Parameters:
      lut - The ModelLUT that these functions are read to
      Throws:
      IOException - if there is an error reading the file
    • readFunctions

      public void readFunctions(ModelRGB rgb) throws IOException
      This method reads the transfers for a RGB image.
      Parameters:
      rgb - The ModelRGB that these functions are read to
      Throws:
      IOException - if there is an error reading the file
    • readLUTandTransferFunction

      public void readLUTandTransferFunction(boolean quietMode) throws IOException
      This method reads a LUT file and its associated transfer function.
      Parameters:
      quietMode - if true indicates that warnings should not be displayed.
      Throws:
      IOException - if there is an error reading the file
    • readLUTandTransferFunction

      public void readLUTandTransferFunction(ModelLUT lut, boolean quietMode) throws IOException
      This method reads a LUT file and its associated transfer function.
      Parameters:
      lut - The ModelLUT that the LUT data gets applied to
      quietMode - if true indicates that warnings should not be displayed.
      Throws:
      IOException - if there is an error reading the file
    • readTransferFunction

      private void readTransferFunction(RandomAccessFile file, TransferFunction funct, String functName) throws IOException
      Reads in a transfer function from a file.
      Parameters:
      file - the file to read from
      funct - the function to add points to
      functName - the transfer function name
      Throws:
      IOException - if there is a problem reading from the file
    • setLUT

      public void setLUT(ModelLUT lut) throws IOException
      Accessor to set the LUT.
      Parameters:
      lut - the ModelLUT
      Throws:
      IOException - if lut is null
    • setImg

      public void setImg(ModelImage img)
      Parameters:
      img - the img to set
    • setOpacityFunction

      public void setOpacityFunction(TransferFunction opacFunction)
      Sets the opacity function, which indicates that we want it to be saved / read in with the rest of the transfer functions.
      Parameters:
      opacFunction - the (grayscale) opacity function
    • setRGB

      public void setRGB(ModelRGB rgb) throws IOException
      Accessor to set the RGB.
      Parameters:
      rgb - the ModelRGB
      Throws:
      IOException - if rgb is null
    • write

      public void write() throws IOException
      Writes the default ModelLUT or ModelRGB to a file.
      Throws:
      IOException - if there is an error writing the file
    • writeAll

      public void writeAll() throws IOException
      Writes the default ModelLUT or ModelRGB to a file. Also writes the functions for a ModelLUT.
      Throws:
      IOException - if there is an error writing the file
    • writeFunctions

      public void writeFunctions() throws IOException
      Writes the transfer and RGB functions to a file.
      Throws:
      IOException - if there is an error writing the file
    • writeLUTandTransferFunction

      public void writeLUTandTransferFunction() throws IOException
      Writes the default ModelLUT or ModelRGB to a file. Also writes the functions for a ModelLUT.
      Throws:
      IOException - if there is an error writing the file
    • writeLUT

      public void writeLUT(ModelLUT lut) throws IOException
      Writes a ModelLUT to a file.
      Parameters:
      lut - ModelLUT to write
      Throws:
      IOException - if there is an error writing the file
    • writeTransferFunction

      public void writeTransferFunction(RandomAccessFile file, TransferFunction funct, String name) throws IOException
      Write out a transfer function to a file.
      Parameters:
      file - the file to write the function to
      funct - the transfer function
      name - the label to apply to the function data
      Throws:
      IOException - if there is a problem writing out to the file
    • parseString

      private static float[] parseString(String s, int len) throws Exception
      Parses a string and returns an array of floats.
      Parameters:
      s - string to be parsed
      len - length of desired array
      Returns:
      array of floats
      Throws:
      Exception - if there is a problem reading in the float values
    • readLine

      private static String readLine(RandomAccessFile file) throws IOException
      Reads a line of the file and strips comments indicated by the # symbol.
      Parameters:
      file - the file to read from
      Returns:
      the line read in
      Throws:
      IOException - if there is an error reading the file