/usr/include/InsightToolkit/IO/itkAnalyzeImageIO.h is in libinsighttoolkit3-dev 3.20.1+git20120521-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | /*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: itkAnalyzeImageIO.h
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
/**
* \file Much of the code for this file reader/writer was taken from
* the University of Iowa Imaging Group library with the
* permission of the authors, Milan Sonka, Joseph Reinhardt,
* Ryan Long, Hans Johnson, Gary Christensen, and others.
* The specification for this file format is taken from the
* web site http://www.mayo.edu/bir/PDF/ANALYZE75.pdf.
* \author Hans J. Johnson
* The University of Iowa 2002
*/
#ifndef __itkAnalyzeImageIO_h
#define __itkAnalyzeImageIO_h
#ifdef _MSC_VER
#pragma warning ( disable : 4786 )
#endif
#include <fstream>
#include "itkImageIOBase.h"
#include "itkAnalyzeDbh.h"
namespace itk
{
/** \class AnalyzeImageIO
* \ingroup IOFilters
* \author Hans J. Johnson
* \brief Class that defines how to read Analyze file format.
* Analyze IMAGE FILE FORMAT - As much information as I can determine from the Medical image
* formats web site, and the Analyze75.pdf file provided from the Mayo clinic.
* A special note of thanks to Dennis P. Hanson (dph@mayo.edu) for his generous contributions
* in getting this information correct.
*
* Analyze image file sets consist of at least 2 files:
* REQUIRED:
* - an image file ([basename].img or [basename].img.gz or [basename].img.Z)
* This contains the binary represenation of the raw voxel values.
* If the file is uncompressed, it should be of of size (sizeof(storagetype)*NX*NY*NZ(*NT).
* The format of the image file is very simple; containing usually
* uncompressed voxel data for the images in one of the several
* possible voxel formats:
* - 1 bit packed binary (slices begin on byte boundaries)
* - 8 bit (unsigned char) gray scale unless .lkup file present
* - 16 bit signed short
* - 32 bit signed integers or float
* - 24 bit RGB, 8 bits per channel
* - a header file ([basename].hdr)
* This a 348 byte file 99.99% of all images that contains a binary represenation of the C-struct
* defined in this file. The analyze 7.5 header structure may, however, be extended beyond this minimal defintion
* to encompase site specific information, and would have more than 348 bytes. Given that the
* ability to extend the header has rarely been used, this implementation of the Analyze 7.5
* file will only read the first 348 bytes into the structure defined in this file, and all informaiton beyond the
* 348 bytes will be ignored.
* OPTIONAL:
* - a color lookup file ([basename].lkup)
* The .lkup file is a plain ASCII text file that contains 3 integer values between 0 and 255
* on each line. Each line of the lkup file represents one color table entry for the Red,
* Green and Blue color components, respectively. The total dynamic range of the image
* is divided by the number of colors in color table to determine mapping of the image through
* these colors.
* For example, an 8-color 'rainbow colors' lookup table is represented as:
* ===========================
* 255 0 0
* 255 128 0
* 255 255 0
* 128 255 0
* 0 255 0
* 0 0 255
* 128 0 255
* 255 0 255
* ===========================
* - an object file ([basename].obj)
* A specially formated file with a mapping between object name and image code used to associate
* image voxel locations with a label. This file is run length encoded to save disk storage.
*/
class ITK_EXPORT AnalyzeImageIO : public ImageIOBase
{
public:
/** Standard class typedefs. */
typedef AnalyzeImageIO Self;
typedef ImageIOBase Superclass;
typedef SmartPointer<Self> Pointer;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(AnalyzeImageIO, Superclass);
/*-------- This part of the interfaces deals with reading data. ----- */
/** Determine if the file can be read with this ImageIO implementation.
* \author Hans J Johnson
* \param FileNameToRead The name of the file to test for reading.
* \post Sets classes ImageIOBase::m_FileName variable to be FileNameToWrite
* \return Returns true if this ImageIO can read the file specified.
*/
virtual bool CanReadFile(const char* FileNameToRead);
/** Set the spacing and dimension information for the set filename. */
virtual void ReadImageInformation();
/** Reads the data from disk into the memory buffer provided. */
virtual void Read(void* buffer);
/*-------- This part of the interfaces deals with writing data. ----- */
/** Determine if the file can be written with this ImageIO implementation.
* \param FileNameToWrite The name of the file to test for writing.
* \author Hans J. Johnson
* \post Sets classes ImageIOBase::m_FileName variable to be FileNameToWrite
* \return Returns true if this ImageIO can write the file specified.
*/
virtual bool CanWriteFile(const char * FileNameToWrite);
/** Set the spacing and dimension information for the set filename. */
virtual void WriteImageInformation();
/** Writes the data to disk from the memory buffer provided. Make sure
* that the IORegions has been set properly. */
virtual void Write(const void* buffer);
/** Return the directions with a correction for the 2D case. */
virtual std::vector<double> GetDirection(unsigned int i) const;
/** Return the directions to be assigned by default to recipient
* images whose dimension is smaller than the image dimension in file. */
virtual std::vector<double> GetDefaultDirection(unsigned int i) const;
protected:
AnalyzeImageIO();
~AnalyzeImageIO();
void PrintSelf(std::ostream& os, Indent indent) const;
private:
/**
* \enum ValidAnalyzeOrientationFlags
* Valid Orientation values for objects
* - Key Description Origin dims[1] dims[2] dims[3]
* - =================================================================
* - 0 transverse-unflipped IRP R->L P->A I->S
* - 1 coronal-unflipped IRP R->L I->S P->A
* - 2 sagittal-unflipped IRP P->A I->S R->L
* - 3 transverse-flipped IRA R->L A->P I->S
* - 4 coronal-flipped SRP R->L S->I P->A
* - 5 sagittal-flipped ILP P->A I->S L->R
* - Where the Origin disignators are with respect to the patient
* - [(I)nferior|(S)uperior] [(L}eft|(R)ight] [(A)nterior|(P)osterior]
* \note Key's 0-5 correspond to the Analyze v7.5 orientations, and should not be changed.
*/
typedef enum
{
ITK_ANALYZE_ORIENTATION_RPI_TRANSVERSE=0, /**< Denotes a transverse data orientation Right-->Left, */
ITK_ANALYZE_ORIENTATION_RIP_CORONAL =1, /**< Denotes a coronal data orientation */
ITK_ANALYZE_ORIENTATION_PIR_SAGITTAL =2, /**< Denotes a sagittal data orientation */
ITK_ANALYZE_ORIENTATION_RAI_TRANSVERSE_FLIPPED=3,/**< */
ITK_ANALYZE_ORIENTATION_RSP_CORONAL_FLIPPED=4, /**< */
ITK_ANALYZE_ORIENTATION_PIL_SAGITTAL_FLIPPED=5 /**< */
} ValidAnalyzeOrientationFlags;
AnalyzeImageIO(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
void SwapBytesIfNecessary(void * buffer, SizeType numberOfPixels);
/**
* \author Hans J. Johnson
* Performs byte swapping of the Analyze Image header if necessary.
* \param imageheader An Analyze 7.5 compliant image header.
* \return void
*/
void SwapHeaderBytesIfNecessary( struct dsr * const imageheader );
/**
* \author Hans J. Johnson
* Defines the header object data type feilds according to Analyze v7.5 specifications
* \return nothing
*/
void DefineHeaderObjectDataType(void);
#if defined(REORIENT_IMAGES)
void ReorientIfNecessary(char *p);
struct ipl_dimensions
{
unsigned int slicestride;
unsigned int rowstride;
unsigned int componentstride;x
unsigned int pixelsize;
//
// xsize,ysize,zsize == size in each direction in pixesls
unsigned int xsize;
unsigned int ysize;
unsigned int zsize;
};
/**
* \author Kent Williams
* Get values needed to re-orient image data to
* Coronal scan order
* \param dim - structure to fill in
* \return nothing
*/
void GetAllDimensions(ipl_dimensions &dim);
ipl_dimensions m_OldDim,m_NewDim;
#endif
/**
* \author Hans J. Johnson
* Check the endedness of the header file.
* \param temphdr - a reference to the header structure
* \return The endedness of the file
*/
ImageIOBase::ByteOrder CheckAnalyzeEndian(const struct dsr &temphdr);
/** All of the information read in from the header file */
struct dsr m_Hdr;
ImageIOBase::ByteOrder m_MachineByteOrder;
};
extern const char *const ANALYZE_ScanNumber;
extern const char *const ANALYZE_O_MAX;
extern const char *const ANALYZE_O_MIN;
extern const char *const ANALYZE_S_MAX;
extern const char *const ANALYZE_S_MIN;
extern const char *const ANALYZE_CAL_MAX;
extern const char *const ANALYZE_CAL_MIN;
extern const char *const ANALYZE_GLMAX;
extern const char *const ANALYZE_GLMIN;
extern const char *const ANALYZE_AUX_FILE_NAME;
extern const char *const ANALYZE_CALIBRATIONUNITS;
} // end namespace itk
#endif // __itkAnalyzeImageIO_h
|