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 Details

    • 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 File file
      DOCUMENT ME!
    • fileDir

      private String fileDir
      DOCUMENT ME!
    • fileInfo

      private FileInfoFits fileInfo
      DOCUMENT ME!
    • fileInfoCopy

      private FileInfoFits fileInfoCopy
    • fileName

      private 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
  • Constructor Details

    • FileFits

      public FileFits(String fileName, String fileDir) throws IOException
      FITS reader/writer constructor.
      Parameters:
      fileName - file name
      fileDir - file directory
      Throws:
      IOException - if there is an error making the file
  • Method Details

    • finalize

      public void finalize()
      Prepares this class for cleanup. Calls the finalize method for existing elements, closes any open files and sets other elements to null.
      Overrides:
      finalize in class FileBase
    • getModelLUT

      public ModelLUT getModelLUT()
      returns LUT if defined.
      Returns:
      the LUT if defined else it is null
    • readImage

      public ModelImage readImage(boolean one) throws IOException
      reads the FITS file header and data.
      Parameters:
      one - DOCUMENT ME!
      Returns:
      DOCUMENT ME!
      Throws:
      IOException - if there is an error reading the file
    • writeImage

      public void writeImage(ModelImage image, FileWriteOptions options) throws 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:
      IOException - if there is an error writing the file
    • readBuffer

      private void readBuffer(int slice, float[] buffer, float scaleFact, float scaleOffset) throws 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 array
      buffer - buffer where the info is stored
      scaleFact - if 1 data is unscaled
      scaleOffset - if 0 don't add offset
      Throws:
      IOException - if there is an error reading the file
    • readDBuffer

      private void readDBuffer(int slice, double[] buffer, double scaleFact, double scaleOffset) throws 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 array
      buffer - buffer where the info is stored
      scaleFact - if 1 data is unscaled
      scaleOffset - if 0 don't add offset
      Throws:
      IOException - if there is an error reading the file