Package gov.nih.mipav.model.file
Class FileSTK
java.lang.Object
gov.nih.mipav.model.file.FileBase
gov.nih.mipav.model.file.FileSTK
The MetaMorph Stack (STK) file format is derived from the TIFF format. Note that the IMAGE_DESCRIPTION and
STRIP_OFFSETS tags are handled differently in STK file format than in TIFF file format. Also note that the UIC1Tag,
UIC2Tag, UIC3Tag, and UIC4Tag are found in STK but not in TIFF. While TIFF files can be either big-endian or
little-endian, STK files must be little endian. Only packed bit compression is supported at this time. Note that
although EchoTech has a tResolution field, there is no provision for 4D in TIFF.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classSimple class to store image offsets and bytes located at the offset. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDOCUMENT ME!static final intDOCUMENT ME!static final intTIFF Types.private byte[]DOCUMENT ME!private booleanDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!private Vector<FileSTK.Index>[]static final intDOCUMENT ME!private byte[]DOCUMENT ME!private booleanDOCUMENT ME!static final intDOCUMENT ME!private booleanDOCUMENT ME!private FileDOCUMENT ME!private StringDOCUMENT ME!private FileInfoSTKDOCUMENT ME!private StringDOCUMENT ME!private FilePackBitDOCUMENT ME!private FileRawChunkDOCUMENT ME!static final intDOCUMENT ME!private int[]DOCUMENT ME!private ModelImageDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!private byte[]DOCUMENT ME!private intDOCUMENT ME!private float[]DOCUMENT ME!private float[]DOCUMENT ME!static final intDOCUMENT ME!private ModelLUTDOCUMENT ME!private intDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!private shortDOCUMENT ME!static final intTIFF Tags.private intDOCUMENT ME!private intDOCUMENT ME!private booleanDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!private intDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!private intDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!private byte[]DOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!private StringDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!private int[]DOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private int[]DOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!private int[]DOCUMENT ME!private intDOCUMENT ME!private doubleDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!private intDOCUMENT ME!static final intDOCUMENT ME!private intDOCUMENT ME!static final intDOCUMENT ME!private doubleDOCUMENT ME!static final intEchoTech Tiff TAGS.Fields inherited from class gov.nih.mipav.model.file.FileBase
BIG_ENDIAN, bitsPerPixel, fileNames, LITTLE_ENDIAN, pBarVisible, raFile, READ, READ_WRITE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidfinalize()Prepares this class for cleanup.Accessor that returns the file info.float[]Accessor that returns the image buffer.Rreturns LUT if defined.private booleanopenIFD(FileInfoSTK fileInfo) Reads and decodes IFDs (Image File Directory).private voidreadBuffer(int slice, float[] buffer) Reads a slice of data at a time and stores the results in the buffer.readImage(boolean multiFile, boolean one) Reads the Tiff header which indicates endianess, the TIFF magic number, and the offset in bytes of the first IFD.private voidreadTileBuffer(int slice, float[] buffer) Reads a slice of data at a time and stores the results in the buffer.voidsetFileName(String fName) Accessor to set the file name (used when reading TIFF multiFile).private voidwriteColorMap(int location) Writes color map to the TIFF file.private voidWrites TIFF starting file header.private voidwriteIFD(int tag, int type, int count, int value, int value2) Writes one 12 byte IFD entry.private voidwriteIFDs(int imageOffset, int nextIFD, int index, int theStripCount, boolean writePackBit) Writes one IFD (Image File Directory).voidwriteImage(ModelImage image, ModelLUT LUT, FileWriteOptions options) This method writes a STK image file.Methods inherited from class gov.nih.mipav.model.file.FileBase
addProgressChangeListener, bytesToDouble, bytesToFloat, bytesToInt, bytesToShort, doubleToBytes, 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
-
BYTE
public static final int BYTETIFF Types.- See Also:
-
ASCII
public static final int ASCIIDOCUMENT ME!- See Also:
-
SHORT
public static final int SHORTDOCUMENT ME!- See Also:
-
LONG
public static final int LONGDOCUMENT ME!- See Also:
-
RATIONAL
public static final int RATIONALDOCUMENT ME!- See Also:
-
SBYTE
public static final int SBYTEDOCUMENT ME!- See Also:
-
UNDEFINED
public static final int UNDEFINEDDOCUMENT ME!- See Also:
-
SSHORT
public static final int SSHORTDOCUMENT ME!- See Also:
-
SLONG
public static final int SLONGDOCUMENT ME!- See Also:
-
SRATIONAL
public static final int SRATIONALDOCUMENT ME!- See Also:
-
FLOAT
public static final int FLOATDOCUMENT ME!- See Also:
-
DOUBLE
public static final int DOUBLEDOCUMENT ME!- See Also:
-
NEW_SUBFILE_TYPE
public static final int NEW_SUBFILE_TYPETIFF Tags.- See Also:
-
IMAGE_WIDTH
public static final int IMAGE_WIDTHDOCUMENT ME!- See Also:
-
IMAGE_LENGTH
public static final int IMAGE_LENGTHDOCUMENT ME!- See Also:
-
BITS_PER_SAMPLE
public static final int BITS_PER_SAMPLEDOCUMENT ME!- See Also:
-
COMPRESSION
public static final int COMPRESSIONDOCUMENT ME!- See Also:
-
PHOTO_INTERP
public static final int PHOTO_INTERPDOCUMENT ME!- See Also:
-
IMAGE_DESCRIPTION
public static final int IMAGE_DESCRIPTIONDOCUMENT ME!- See Also:
-
STRIP_OFFSETS
public static final int STRIP_OFFSETSDOCUMENT ME!- See Also:
-
SAMPLES_PER_PIXEL
public static final int SAMPLES_PER_PIXELDOCUMENT ME!- See Also:
-
ROWS_PER_STRIP
public static final int ROWS_PER_STRIPDOCUMENT ME!- See Also:
-
STRIP_BYTE_COUNTS
public static final int STRIP_BYTE_COUNTSDOCUMENT ME!- See Also:
-
MIN_SAMPLE_VALUE
public static final int MIN_SAMPLE_VALUEDOCUMENT ME!- See Also:
-
MAX_SAMPLE_VALUE
public static final int MAX_SAMPLE_VALUEDOCUMENT ME!- See Also:
-
XRESOLUTION
public static final int XRESOLUTIONDOCUMENT ME!- See Also:
-
YRESOLUTION
public static final int YRESOLUTIONDOCUMENT ME!- See Also:
-
PLANAR_CONFIG
public static final int PLANAR_CONFIGDOCUMENT ME!- See Also:
-
RESOLUTION_UNIT
public static final int RESOLUTION_UNITDOCUMENT ME!- See Also:
-
SOFTWARE
public static final int SOFTWAREDOCUMENT ME!- See Also:
-
DATE_TIME
public static final int DATE_TIMEDOCUMENT ME!- See Also:
-
PREDICTOR
public static final int PREDICTORDOCUMENT ME!- See Also:
-
COLOR_MAP
public static final int COLOR_MAPDOCUMENT ME!- See Also:
-
TILE_WIDTH
public static final int TILE_WIDTHDOCUMENT ME!- See Also:
-
TILE_LENGTH
public static final int TILE_LENGTHDOCUMENT ME!- See Also:
-
TILE_OFFSETS
public static final int TILE_OFFSETSDOCUMENT ME!- See Also:
-
TILE_BYTE_COUNTS
public static final int TILE_BYTE_COUNTSDOCUMENT ME!- See Also:
-
SAMPLE_FORMAT
public static final int SAMPLE_FORMATDOCUMENT ME!- See Also:
-
UIC1Tag
public static final int UIC1TagDOCUMENT ME!- See Also:
-
UIC2Tag
public static final int UIC2TagDOCUMENT ME!- See Also:
-
UIC3Tag
public static final int UIC3TagDOCUMENT ME!- See Also:
-
UIC4Tag
public static final int UIC4TagDOCUMENT ME!- See Also:
-
ZRESOLUTION
public static final int ZRESOLUTIONEchoTech Tiff TAGS.- See Also:
-
TRESOLUTION
public static final int TRESOLUTIONDOCUMENT ME!- See Also:
-
byteBuffer
private byte[] byteBufferDOCUMENT ME! -
chunky
private boolean chunkyDOCUMENT ME! -
dataOffsets
-
dateTime
private byte[] dateTimeDOCUMENT ME! -
doTile
private boolean doTileDOCUMENT ME! -
endianess
private boolean endianessDOCUMENT ME! -
file
DOCUMENT ME! -
fileDir
DOCUMENT ME! -
fileInfo
DOCUMENT ME! -
fileName
DOCUMENT ME! -
filePB
DOCUMENT ME! -
fileRW
DOCUMENT ME! -
IFDoffsets
private int[] IFDoffsetsDOCUMENT ME! -
image
DOCUMENT ME! -
imageDescription
private byte[] imageDescriptionDOCUMENT ME! -
imageSlice
private int imageSliceDOCUMENT ME! -
imgBuffer
private float[] imgBufferDOCUMENT ME! -
imgResols
private float[] imgResolsDOCUMENT ME! -
LUT
DOCUMENT ME! -
LUTOffset
private int LUTOffsetDOCUMENT ME! -
nDirEntries
private short nDirEntriesDOCUMENT ME! -
numberImages
private int numberImagesDOCUMENT ME! -
offsetConstant
private int offsetConstantDOCUMENT ME! -
packBit
private boolean packBitDOCUMENT ME! -
planeOffset
private int planeOffsetDOCUMENT ME! -
samplesPerPixel
private int samplesPerPixelDOCUMENT ME! -
software
private byte[] softwareDOCUMENT ME! -
str
DOCUMENT ME! -
tileByteCounts
private int[] tileByteCountsDOCUMENT ME! -
tileByteNumber
private int tileByteNumberDOCUMENT ME! -
tileLength
private int tileLengthDOCUMENT ME! -
tileOffsetNumber
private int tileOffsetNumberDOCUMENT ME! -
tileOffsets
private int[] tileOffsetsDOCUMENT ME! -
tilesAcross
private int tilesAcrossDOCUMENT ME! -
tilesDown
private int tilesDownDOCUMENT ME! -
tilesPerImage
private int tilesPerImageDOCUMENT ME! -
tilesPerSlice
private int tilesPerSliceDOCUMENT ME! -
tileTemp
private int[] tileTempDOCUMENT ME! -
tileWidth
private int tileWidthDOCUMENT ME! -
tRes
private double tResDOCUMENT ME! -
xDim
private int xDimDOCUMENT ME! -
yDim
private int yDimDOCUMENT ME! -
zRes
private double zResDOCUMENT ME!
-
-
Constructor Details
-
FileSTK
STK reader/writer constructor.- Parameters:
fileName- file namefileDir- file directory- Throws:
IOException- if there is an error making the file
-
-
Method Details
-
finalize
public void finalize()Prepares this class for cleanup. Calls thefinalizemethod for existing elements, closes any open files and sets other elements tonull. -
getFileInfo
Accessor that returns the file info.- Returns:
- FileInfoBase containing the file info
-
getImageBuffer
public float[] getImageBuffer()Accessor that returns the image buffer.- Returns:
- buffer of image.
-
getModelLUT
Rreturns LUT if defined.- Returns:
- the LUT if defined else it is null
-
readImage
Reads the Tiff header which indicates endianess, the TIFF magic number, and the offset in bytes of the first IFD. It then reads all the IFDs. This method then opens a Model of an image and imports the the images one slice at a time. Image slices are separated by an IFD.- Parameters:
multiFile-trueif a set of files each containing a separate 2D image is presentfalseif one file with either a 2D image or a stack of 2D imagesone- DOCUMENT ME!- Returns:
- returns the image
- Throws:
IOException- if there is an error reading the file
-
setFileName
Accessor to set the file name (used when reading TIFF multiFile).- Parameters:
fName- file name of image to read.
-
writeImage
This method writes a STK image file.- Parameters:
image- image model where the data is stored.LUT- LUT to be saved with image if not null.options- DOCUMENT ME!- Throws:
IOException- if there is an error writing the file.
-
openIFD
Reads and decodes IFDs (Image File Directory).- Parameters:
fileInfo- DOCUMENT ME!- Returns:
- DOCUMENT ME!
- Throws:
IOException- if there is an error reading the file
-
readBuffer
Reads a slice of data at a time and stores the results in the buffer.- Parameters:
slice- offset into the file stored in the dataOffset arraybuffer- buffer where the info is stored- Throws:
IOException- if there is an error reading the file
-
readTileBuffer
Reads a slice of data at a time and stores the results in the buffer.- Parameters:
slice- image slicebuffer- buffer where the info is stored- Throws:
IOException- if there is an error reading the file
-
writeColorMap
Writes color map to the TIFF file.- Parameters:
location- Location to write at.- Throws:
IOException- DOCUMENT ME!
-
writeHeader
Writes TIFF starting file header.- Throws:
IOException- DOCUMENT ME!
-
writeIFD
Writes one 12 byte IFD entry.- Parameters:
tag- DOCUMENT ME!type- DOCUMENT ME!count- DOCUMENT ME!value- DOCUMENT ME!value2- DOCUMENT ME!- Throws:
IOException- DOCUMENT ME!
-
writeIFDs
private void writeIFDs(int imageOffset, int nextIFD, int index, int theStripCount, boolean writePackBit) throws IOException Writes one IFD (Image File Directory). One IFD per image- Parameters:
imageOffset- offset to next IFD. If equal to zero then end of imagesnextIFD- DOCUMENT ME!index- image index for file information.theStripCount- DOCUMENT ME!writePackBit- DOCUMENT ME!- Throws:
IOException- DOCUMENT ME!
-