Package gov.nih.mipav.model.file
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:
ModelLUT
,ModelRGB
,JFrameHistogram
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
endTag
Tag marking the end of a LUT or transfer file.private java.lang.String
fileDir
The file directory containing the data files.private java.lang.String
funcFileName
The file name of the transfer function data file.private static java.lang.String
funcTag
Tag marking the beginning of a transfer function file.private ModelImage
img
ModelImage to use for referenceprivate ModelLUT
lut
The (grayscale) LUT to save.private java.lang.String
lutFileName
The file name of the LUT data file.private static java.lang.String
lutTag
Tag marking the beginning of a LUT data file.private TransferFunction
opacityFunction
The opacity transfer function, saved if non-null.private ModelRGB
rgb
The color image histogram data to save.private boolean
useLUT
Whether to use the LUT or the RGB model.-
Fields inherited from class gov.nih.mipav.model.file.FileBase
BIG_ENDIAN, bitsPerPixel, fileNames, LITTLE_ENDIAN, pBarVisible, raFile, READ, READ_WRITE
-
-
Constructor Summary
Constructors Constructor Description FileHistoLUT(java.lang.String fileName, java.lang.String fileDir)
LUT reader/writer constructor.FileHistoLUT(java.lang.String fileName, java.lang.String fileDir, ModelImage image, ModelLUT lut)
LUT reader/writer constructor.FileHistoLUT(java.lang.String fileName, java.lang.String fileDir, ModelImage image, ModelRGB rgb)
RGB reader/writer constructor.FileHistoLUT(java.lang.String fileName, java.lang.String fileDir, ModelImage image, ModelStorageBase lut)
LUT reader/writer constructor.FileHistoLUT(java.lang.String fileName, java.lang.String fileDir, ModelLUT lut)
LUT reader/writer constructor.FileHistoLUT(java.lang.String fileName, java.lang.String fileDir, ModelRGB rgb)
RGB reader/writer constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static float[]
parseString(java.lang.String s, int len)
Parses a string and returns an array of floats.void
readFunctions()
This method reads the transfer and RGB functions associated with a LUT.void
readFunctions(ModelLUT lut)
This method reads the transfer for a grayscale image and the RGB functions that define the LUT.void
readFunctions(ModelRGB rgb)
This method reads the transfers for a RGB image.private static java.lang.String
readLine(java.io.RandomAccessFile file)
Reads a line of the file and strips comments indicated by the # symbol.void
readLUTandTransferFunction(boolean quietMode)
This method reads a LUT file and its associated transfer function.void
readLUTandTransferFunction(ModelLUT lut, boolean quietMode)
This method reads a LUT file and its associated transfer function.private void
readTransferFunction(java.io.RandomAccessFile file, TransferFunction funct, java.lang.String functName)
Reads in a transfer function from a file.void
setImg(ModelImage img)
void
setLUT(ModelLUT lut)
Accessor to set the LUT.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.void
setRGB(ModelRGB rgb)
Accessor to set the RGB.void
write()
Writes the default ModelLUT or ModelRGB to a file.void
writeAll()
Writes the default ModelLUT or ModelRGB to a file.void
writeFunctions()
Writes the transfer and RGB functions to a file.void
writeLUT(ModelLUT lut)
Writes a ModelLUT to a file.void
writeLUTandTransferFunction()
Writes the default ModelLUT or ModelRGB to a file.void
writeTransferFunction(java.io.RandomAccessFile file, TransferFunction funct, java.lang.String name)
Write out a transfer function to a file.-
Methods inherited from class gov.nih.mipav.model.file.FileBase
addProgressChangeListener, bytesToDouble, bytesToFloat, bytesToInt, bytesToShort, doubleToBytes, finalize, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, floatToBytes, getBufferDouble, getBufferFloat, getBufferInt, getBufferLong, getBufferShort, getBufferUShort, getDataType, getDouble, getFloat, getInt, getLong, getProgressChangeListeners, getRaFile, getSignedShort, getString, getUInt, getUnsignedByte, getUnsignedShort, intToBytes, isBigEndian, isProgressBarVisible, linkProgress, longToBytes, readDouble, readFloat, readInt, readLong, readShort, readString, readUnsignedShort, removeProgressChangeListener, setBigEndian, setBufferFloat, setBufferInt, setBufferLong, setBufferShort, setBufferString, setDataType, setEndianess, shortToBytes, writeBytes, writeDouble, writeFloat, writeInt, writeLong, writeShort
-
-
-
-
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 namefileDir
- 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 namefileDir
- file directorylut
- 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 namefileDir
- file directorylut
- 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 namefileDir
- file directorylut
- 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 namefileDir
- file directoryrgb
- 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 namefileDir
- file directoryrgb
- 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 toquietMode
- 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 fromfunct
- the function to add points tofunctName
- 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 tofunct
- the transfer functionname
- 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 parsedlen
- 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
-
-