Package gov.nih.mipav.model.file
Class FileFits
- java.lang.Object
-
- gov.nih.mipav.model.file.FileBase
-
- gov.nih.mipav.model.file.FileFits
-
public class FileFits extends FileBase
Some of this code is derived from FITS.java in ImageJ. In A User's Guide for the Flexible Image Transport System (FITS) Version 4.0, Section 4.1 Indexes and Physical Coordinates, the text says, "Historically, astronomers have generally assumed that the index point in a FITS file represents the center of a pixel. This interpretation is endorsed by GC. It differs from the common practice in computer graphics of treating the center of a pixel as a half-integral point." For CRPIXn in FITS: The center of the first pixel is 1 and the center of the last pixel is NAXISn. In MIPAV the center of the first pixel is 0.5 and the center of the last pixel is NAXISn - 0.5. So subtract 0.5 to go from FITS to MIPAV. " ...recommend that FITS writers order pixels starting in the lower left hand corner of the image, with the first axis increasing to the right, as in the rectangular coordinate x-axis, and the second increasing upward (the y-axis)." MIPAV uses the upper left hand corner as the origin and has the y axis going downward. Therefore, the image is flipped after reading and flipped before writing.
ImageJ disclaimer:
ImageJ is being developed at the National Institutes of Health by an employee of the Federal Government in the course of his official duties. Pursuant to Title 17, Section 105 of the United States Code, this software is not subject to copyright protection and is in the public domain. ImageJ is an experimental system. NIH assumes no responsibility whatsoever for its use by other parties, and makes no guarantees, expressed or implied, about its quality, reliability, or any other characteristic.
-
-
Field Summary
Fields Modifier and Type Field Description private int
BLANK
DOCUMENT ME!private boolean
endianess
DOCUMENT ME!private java.io.File
file
DOCUMENT ME!private java.lang.String
fileDir
DOCUMENT ME!private FileInfoFits
fileInfo
DOCUMENT ME!private FileInfoFits
fileInfoCopy
private java.lang.String
fileName
DOCUMENT ME!private AlgorithmFlip
flipAlgo
private boolean
haveBlank
DOCUMENT ME!private ModelImage
image
DOCUMENT ME!(package private) int[]
imgExtents
DOCUMENT ME!private boolean
isColorPlanar2D
private ModelLUT
LUT
DOCUMENT ME!(package private) int
nDimensions
DOCUMENT ME!private int
numberSlices
DOCUMENT ME!(package private) int
sourceType
DOCUMENT ME!-
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 FileFits(java.lang.String fileName, java.lang.String fileDir)
FITS reader/writer constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
finalize()
Prepares this class for cleanup.ModelLUT
getModelLUT()
returns LUT if defined.private void
readBuffer(int slice, float[] buffer, float scaleFact, float scaleOffset)
Reads a slice of data at a time and stores the results in the buffer.private void
readDBuffer(int slice, double[] buffer, double scaleFact, double scaleOffset)
Reads a slice of data at a time and stores the results in the buffer.ModelImage
readImage(boolean one)
reads the FITS file header and data.void
writeImage(ModelImage image, FileWriteOptions options)
Writes a FITS format type image.-
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 Detail
-
imgExtents
int[] imgExtents
DOCUMENT ME!
-
nDimensions
int nDimensions
DOCUMENT ME!
-
sourceType
int sourceType
DOCUMENT ME!
-
BLANK
private int BLANK
DOCUMENT ME!
-
endianess
private boolean endianess
DOCUMENT ME!
-
file
private java.io.File file
DOCUMENT ME!
-
fileDir
private java.lang.String fileDir
DOCUMENT ME!
-
fileInfo
private FileInfoFits fileInfo
DOCUMENT ME!
-
fileInfoCopy
private FileInfoFits fileInfoCopy
-
fileName
private java.lang.String fileName
DOCUMENT ME!
-
haveBlank
private boolean haveBlank
DOCUMENT ME!
-
image
private ModelImage image
DOCUMENT ME!
-
LUT
private ModelLUT LUT
DOCUMENT ME!
-
numberSlices
private int numberSlices
DOCUMENT ME!
-
isColorPlanar2D
private boolean isColorPlanar2D
-
flipAlgo
private AlgorithmFlip flipAlgo
-
-
Method Detail
-
finalize
public void finalize()
Prepares this class for cleanup. Calls thefinalize
method for existing elements, closes any open files and sets other elements tonull
.
-
getModelLUT
public ModelLUT getModelLUT()
returns LUT if defined.- Returns:
- the LUT if defined else it is null
-
readImage
public ModelImage readImage(boolean one) throws java.io.IOException
reads the FITS file header and data.- Parameters:
one
- DOCUMENT ME!- Returns:
- DOCUMENT ME!
- Throws:
java.io.IOException
- if there is an error reading the file
-
writeImage
public void writeImage(ModelImage image, FileWriteOptions options) throws java.io.IOException
Writes a FITS format type image.- Parameters:
image
- Image model of data to write.options
- options such as starting and ending slices and times- Throws:
java.io.IOException
- if there is an error writing the file
-
readBuffer
private void readBuffer(int slice, float[] buffer, float scaleFact, float scaleOffset) throws java.io.IOException
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 storedscaleFact
- if 1 data is unscaledscaleOffset
- if 0 don't add offset- Throws:
java.io.IOException
- if there is an error reading the file
-
readDBuffer
private void readDBuffer(int slice, double[] buffer, double scaleFact, double scaleOffset) throws java.io.IOException
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 storedscaleFact
- if 1 data is unscaledscaleOffset
- if 0 don't add offset- Throws:
java.io.IOException
- if there is an error reading the file
-
-