ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkMGHImageIO.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18
19#ifndef itkMGHImageIO_h
20#define itkMGHImageIO_h
21
22#include "itkMatrix.h"
23#include "itkImageIOBase.h"
24#include <fstream>
25#include "itk_zlib.h"
26
27#include "MGHIOExport.h"
28
29namespace itk
30{
41class MGHIO_EXPORT MGHImageIO : public ImageIOBase
42{
43public:
48
50 itkNewMacro(Self);
51
53 itkOverrideGetNameOfClassMacro(MGHImageIO);
54
55 /*-------- This part of the interfaces deals with reading data. ----- */
56
62 bool
63 CanReadFile(const char * FileNameToRead) override;
64
66 void
68
70 void
71 Read(void * pData) override;
72
73 /*-------- This part of the interfaces deals with writing data. ----- */
74
80 bool
81 CanWriteFile(const char * name) override;
82
84 void
86
89 void
90 Write(const void * buffer) override;
91
92protected:
94 ~MGHImageIO() override;
95 void
96 PrintSelf(std::ostream & os, Indent indent) const override;
97
98 void
100
101private:
102 static const int MRI_UCHAR = 0;
103 static const int MRI_INT = 1;
104 static const int MRI_FLOAT = 3;
105 static const int MRI_SHORT = 4;
106 static const int MRI_TENSOR = 6;
107 static const unsigned int FS_DIMENSION_HEADER_SIZE = sizeof(int) * 7;
108 static const unsigned int FS_RAS_HEADER_SIZE = (sizeof(float) * 15) + sizeof(short);
109 static const unsigned int FS_UNUSED_HEADER_SIZE = 256 - FS_RAS_HEADER_SIZE;
110 static const unsigned int FS_WHOLE_HEADER_SIZE =
112
114 bool
115 IsCompressedFilename(const std::string fname);
117 void
118 SwapBytesIfNecessary(void * const buffer, const unsigned long numberOfPixels);
119
121 // void MriDirCos();
122
123 void
125
126 void
127 WriteData(const void * buffer);
128
129 void
130 PermuteFrameValues(const void * buffer, char * tempmemory);
131
132 unsigned int
133 GetComponentSize() const override;
134
135 std::string
137
139 gzFile m_GZFile;
140 std::ofstream m_Output;
141
142 // Utility function to assist with writing to disk in the
143 // proper format. TInType is static_cast<TDiskType> type.
144 template <typename TInType, typename TDiskType>
145 int
146 TWrite(const TInType inValue);
147 template <typename TDiskType, typename TOutType>
148 int
149 TRead(TOutType & outValue);
150
151 int
152 TWrite(const char * buf, const unsigned long count);
153 void
155 void
157};
158} // end namespace itk
159
160#endif // itkMGHImageIO_h
Control indentation during Print() invocation.
Definition itkIndent.h:50
static const int MRI_SHORT
std::string GetOrientation(itk::Matrix< double > directions)
bool CanReadFile(const char *FileNameToRead) override
void Write(const void *buffer) override
bool CanWriteFile(const char *name) override
int TWrite(const TInType inValue)
static const unsigned int FS_DIMENSION_HEADER_SIZE
std::ofstream m_Output
static const int MRI_FLOAT
ImageIOBase Superclass
~MGHImageIO() override
void PrintSelf(std::ostream &os, Indent indent) const override
unsigned int GetComponentSize() const override
void PermuteFrameValues(const void *buffer, char *tempmemory)
int TRead(TOutType &outValue)
SmartPointer< Self > Pointer
void SwapBytesIfNecessary(void *const buffer, const unsigned long numberOfPixels)
processes the actual data buffer
static const unsigned int FS_RAS_HEADER_SIZE
MGHImageIO Self
bool IsCompressedFilename(const std::string fname)
static const unsigned int FS_UNUSED_HEADER_SIZE
void ReadImageInformation() override
static const int MRI_UCHAR
static const int MRI_TENSOR
void WriteHeader()
examines the direction cosines and creates encapsulation data
int TWrite(const char *buf, const unsigned long count)
void ReadVolumeHeader()
void WriteImageInformation() override
void WriteData(const void *buffer)
static const int MRI_INT
void Read(void *pData) override
static const unsigned int FS_WHOLE_HEADER_SIZE
A templated class holding a M x N size Matrix.
Definition itkMatrix.h:53
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....