Class 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:
    ModelLUT, ModelRGB, JFrameHistogram
    • Field Detail

      • lutTag

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

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

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

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

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

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

        private java.lang.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 Detail

      • FileHistoLUT

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

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

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

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

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

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

      • readFunctions

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

        public void readFunctions​(ModelLUT lut)
                           throws java.io.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:
        java.io.IOException - if there is an error reading the file
      • readFunctions

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

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

        public void readLUTandTransferFunction​(ModelLUT lut,
                                               boolean quietMode)
                                        throws java.io.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:
        java.io.IOException - if there is an error reading the file
      • readTransferFunction

        private void readTransferFunction​(java.io.RandomAccessFile file,
                                          TransferFunction funct,
                                          java.lang.String functName)
                                   throws java.io.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:
        java.io.IOException - if there is a problem reading from the file
      • setLUT

        public void setLUT​(ModelLUT lut)
                    throws java.io.IOException
        Accessor to set the LUT.
        Parameters:
        lut - the ModelLUT
        Throws:
        java.io.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 java.io.IOException
        Accessor to set the RGB.
        Parameters:
        rgb - the ModelRGB
        Throws:
        java.io.IOException - if rgb is null
      • write

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

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

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

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

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

        public void writeTransferFunction​(java.io.RandomAccessFile file,
                                          TransferFunction funct,
                                          java.lang.String name)
                                   throws java.io.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:
        java.io.IOException - if there is a problem writing out to the file
      • parseString

        private static float[] parseString​(java.lang.String s,
                                           int len)
                                    throws java.lang.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:
        java.lang.Exception - if there is a problem reading in the float values
      • readLine

        private static java.lang.String readLine​(java.io.RandomAccessFile file)
                                          throws java.io.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:
        java.io.IOException - if there is an error reading the file