ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
rtkXimImageIO.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright RTK Consortium
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 rtkXimImageIO_h
20#define rtkXimImageIO_h
21
22#include "RTKExport.h"
23#include "rtkMacro.h"
24
25// itk include
26#include <itkImageIOBase.h>
27
28#if defined(_MSC_VER) && (_MSC_VER < 1600)
29// SR: taken from
30// #include "msinttypes/stdint.h"
31#else
32# include <cstdint>
33#endif
34
35namespace rtk
36{
37
47class RTK_EXPORT XimImageIO : public itk::ImageIOBase
48{
49public:
54 using PixelType = signed short int;
55 using Int4 = itk::int32_t; // int of 4 bytes as in xim docs
56
57 using Xim_header = struct xim_header
58 {
59 // Actual Header:
60 char sFileType[32];
61 Int4 FileVersion;
62 Int4 SizeX;
63 Int4 SizeY;
64 Int4 dBitsPerPixel;
65 Int4 dBytesPerPixel;
66 Int4 dCompressionIndicator;
67 Int4 lookUpTableSize;
68 Int4 compressedPixelBufferSize;
69 Int4 unCompressedPixelBufferSize;
70 // Header after pixel-data:
71 Int4 binsInHistogram;
72 Int4 * histogramData;
73 Int4 numberOfProperties;
74 unsigned int nPixelOffset;
75 double dCollX1;
76 double dCollX2;
77 double dCollY1;
78 double dCollY2;
79 double dCollRtn;
80 double dCouchVrt;
81 double dCouchLng;
82 double dCouchLat;
83 double dIDUResolutionX; // MUST BE CALCULATED
84 double dIDUResolutionY; //
85 double dImageResolutionX; //
86 double dImageResolutionY; //
87 double dEnergy;
88 double dDoseRate;
89 double dXRayKV;
90 double dXRayMA;
91 double dCTProjectionAngle; // KVSourceRtn in file
92 double dDetectorOffsetX; // KVDetectorLat
93 double dDetectorOffsetY; // KVDetectorLng
94 double dCTNormChamber;
95 double dGatingTimeTag;
96 double dGating4DInfoX;
97 double dGating4DInfoY;
98 double dGating4DInfoZ;
99 // double dGating4DInfoTime;
100 };
101
103
105 itkNewMacro(Self);
106
108 itkOverrideGetNameOfClassMacro(XimImageIO);
109
110 /*-------- This part of the interface deals with reading data. ------ */
111 void
113
114 bool
115 CanReadFile(const char * FileNameToRead) override;
116
117 void
118 Read(void * buffer) override;
119
120 /*-------- This part of the interfaces deals with writing data. ----- */
121 virtual void
122 WriteImageInformation(bool /*keepOfStream*/)
123 {}
124
125 void
127 {
129 }
130
131 bool
132 CanWriteFile(const char * filename) override;
133
134 void
135 Write(const void * buffer) override;
136
137private:
138 template <typename T>
139 size_t
140 SetPropertyValue(char * property_name, Int4 value_length, FILE * fp, Xim_header * xim);
141
144
145}; // end class XimImageIO
146
147} // namespace rtk
148
149#endif /* end #define __rtkXimImageIO_h */
Abstract superclass defines image IO interface.
Implements transparent reference counting.
bool CanWriteFile(const char *filename) override
itk::SmartPointer< Self > Pointer
itk::ImageIOBase Superclass
void ReadImageInformation() override
XimImageIO Self
itk::int32_t Int4
signed short int PixelType
void Write(const void *buffer) override
virtual void WriteImageInformation(bool)
void Read(void *buffer) override
bool CanReadFile(const char *FileNameToRead) override
struct xim_header { char sFileType[32]; Int4 FileVersion; Int4 SizeX; Int4 SizeY; Int4 dBitsPerPixel; Int4 dBytesPerPixel; Int4 dCompressionIndicator; Int4 lookUpTableSize; Int4 compressedPixelBufferSize; Int4 unCompressedPixelBufferSize; Int4 binsInHistogram; Int4 * histogramData; Int4 numberOfProperties; unsigned int nPixelOffset; double dCollX1; double dCollX2; double dCollY1; double dCollY2; double dCollRtn; double dCouchVrt; double dCouchLng; double dCouchLat; double dIDUResolutionX; double dIDUResolutionY; double dImageResolutionX; double dImageResolutionY; double dEnergy; double dDoseRate; double dXRayKV; double dXRayMA; double dCTProjectionAngle; double dDetectorOffsetX; double dDetectorOffsetY; double dCTNormChamber; double dGatingTimeTag; double dGating4DInfoX; double dGating4DInfoY; double dGating4DInfoZ; } Xim_header
vcl_size_t SetPropertyValue(char *property_name, Int4 value_length, FILE *fp, Xim_header *xim)
void WriteImageInformation() override