Package gov.nih.mipav.model.file
Class FileHistoLUT
java.lang.Object
gov.nih.mipav.model.file.FileBase
gov.nih.mipav.model.file.FileHistoLUT
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 Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringTag marking the end of a LUT or transfer file.private StringThe file directory containing the data files.private StringThe file name of the transfer function data file.private static final StringTag marking the beginning of a transfer function file.private ModelImageModelImage to use for referenceprivate ModelLUTThe (grayscale) LUT to save.private StringThe file name of the LUT data file.private static final StringTag marking the beginning of a LUT data file.private TransferFunctionThe opacity transfer function, saved if non-null.private ModelRGBThe color image histogram data to save.private booleanWhether 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
ConstructorsConstructorDescriptionFileHistoLUT(String fileName, String fileDir) LUT reader/writer constructor.FileHistoLUT(String fileName, String fileDir, ModelImage image, ModelLUT lut) LUT reader/writer constructor.FileHistoLUT(String fileName, String fileDir, ModelImage image, ModelRGB rgb) RGB reader/writer constructor.FileHistoLUT(String fileName, String fileDir, ModelImage image, ModelStorageBase lut) LUT reader/writer constructor.FileHistoLUT(String fileName, String fileDir, ModelLUT lut) LUT reader/writer constructor.FileHistoLUT(String fileName, String fileDir, ModelRGB rgb) RGB reader/writer constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate static float[]parseString(String s, int len) Parses a string and returns an array of floats.voidThis method reads the transfer and RGB functions associated with a LUT.voidreadFunctions(ModelLUT lut) This method reads the transfer for a grayscale image and the RGB functions that define the LUT.voidreadFunctions(ModelRGB rgb) This method reads the transfers for a RGB image.private static StringreadLine(RandomAccessFile file) Reads a line of the file and strips comments indicated by the # symbol.voidreadLUTandTransferFunction(boolean quietMode) This method reads a LUT file and its associated transfer function.voidreadLUTandTransferFunction(ModelLUT lut, boolean quietMode) This method reads a LUT file and its associated transfer function.private voidreadTransferFunction(RandomAccessFile file, TransferFunction funct, String functName) Reads in a transfer function from a file.voidsetImg(ModelImage img) voidAccessor to set the LUT.voidsetOpacityFunction(TransferFunction opacFunction) Sets the opacity function, which indicates that we want it to be saved / read in with the rest of the transfer functions.voidAccessor to set the RGB.voidwrite()Writes the default ModelLUT or ModelRGB to a file.voidwriteAll()Writes the default ModelLUT or ModelRGB to a file.voidWrites the transfer and RGB functions to a file.voidWrites a ModelLUT to a file.voidWrites the default ModelLUT or ModelRGB to a file.voidwriteTransferFunction(RandomAccessFile file, TransferFunction funct, 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 Details
-
lutTag
Tag marking the beginning of a LUT data file.- See Also:
-
funcTag
Tag marking the beginning of a transfer function file.- See Also:
-
endTag
Tag marking the end of a LUT or transfer file.- See Also:
-
fileDir
The file directory containing the data files. -
funcFileName
The file name of the transfer function data file. -
lut
The (grayscale) LUT to save. -
lutFileName
The file name of the LUT data file. -
opacityFunction
The opacity transfer function, saved if non-null. -
rgb
The color image histogram data to save. -
useLUT
private boolean useLUTWhether to use the LUT or the RGB model. -
img
ModelImage to use for reference
-
-
Constructor Details
-
FileHistoLUT
LUT reader/writer constructor.- Parameters:
fileName- file namefileDir- file directory- Throws:
IOException- if there is an error making the files
-
FileHistoLUT
LUT reader/writer constructor.- Parameters:
fileName- file namefileDir- file directorylut- 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 namefileDir- file directorylut- 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 namefileDir- file directorylut- the ModelLUT- Throws:
IOException- if there is an error making the files, or if lut is null
-
FileHistoLUT
RGB reader/writer constructor.- Parameters:
fileName- file namefileDir- file directoryrgb- 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 namefileDir- file directoryrgb- the ModelRGB- Throws:
IOException- if there is an error making the files, or if rgb is null
-
-
Method Details
-
readFunctions
This method reads the transfer and RGB functions associated with a LUT.- Throws:
IOException- if there is an error reading the file
-
readFunctions
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
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
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
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:
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 fromfunct- the function to add points tofunctName- the transfer function name- Throws:
IOException- if there is a problem reading from the file
-
setLUT
Accessor to set the LUT.- Parameters:
lut- the ModelLUT- Throws:
IOException- if lut is null
-
setImg
- Parameters:
img- the img to set
-
setOpacityFunction
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
Accessor to set the RGB.- Parameters:
rgb- the ModelRGB- Throws:
IOException- if rgb is null
-
write
Writes the default ModelLUT or ModelRGB to a file.- Throws:
IOException- if there is an error writing the file
-
writeAll
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
Writes the transfer and RGB functions to a file.- Throws:
IOException- if there is an error writing the file
-
writeLUTandTransferFunction
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
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 tofunct- the transfer functionname- the label to apply to the function data- Throws:
IOException- if there is a problem writing out to the file
-
parseString
Parses a string and returns an array of floats.- Parameters:
s- string to be parsedlen- length of desired array- Returns:
- array of floats
- Throws:
Exception- if there is a problem reading in the float values
-
readLine
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
-