go home Home | Main Page | Topics | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
Loading...
Searching...
No Matches
itkNDImageTemplate.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright UMC Utrecht and contributors
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 * http://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#ifndef itkNDImageTemplate_h
19#define itkNDImageTemplate_h
20
21#include "itkNDImageBase.h"
22#include "itkImageFileReader.h"
23#include <algorithm> // For copy_n.
24#include <type_traits> // For is_same_v.
25
26namespace itk
27{
28
45
46template <typename TPixel, unsigned int VDimension>
47class ITK_TEMPLATE_EXPORT NDImageTemplate : public NDImageBase<TPixel>
48{
49public:
51
55 using Pointer = SmartPointer<Self>;
56 using ConstPointer = SmartPointer<const Self>;
57
59 itkNewMacro(Self);
60
63
67
68 itkStaticConstMacro(Dimension, unsigned int, VDimension);
69
70 using typename Superclass::DataObjectPointer;
71
73 using typename Superclass::PixelType;
74 using typename Superclass::ValueType;
75 using typename Superclass::InternalPixelType;
76 using typename Superclass::AccessorType;
77 using typename Superclass::PixelContainer;
80
81 using typename Superclass::SpacingValueType;
82 using typename Superclass::PointValueType;
83 using typename Superclass::OffsetValueType;
84
86 using typename Superclass::IndexType;
87 using typename Superclass::SizeType;
88 using typename Superclass::SpacingType;
89 using typename Superclass::PointType;
90 using typename Superclass::OffsetType;
91
93 using ImageType = Image<TPixel, VDimension>;
94 using ImagePointer = typename ImageType::Pointer;
96 using WriterPointer = typename WriterType::Pointer;
97 using ReaderType = ImageFileReader<ImageType>;
98 using ReaderPointer = typename ReaderType::Pointer;
99
101 using IndexTypeD = typename ImageType::IndexType;
102 using SizeTypeD = typename ImageType::SizeType;
103 using SpacingTypeD = typename ImageType::SpacingType;
104 using PointTypeD = typename ImageType::PointType;
105 using OffsetTypeD = typename ImageType::OffsetType;
106
107 void
108 SetRegions(SizeType size) override;
109
110 void
111 SetRequestedRegion(DataObject * data) override;
112
113 void
114 Allocate() override;
115
116 void
117 Initialize() override;
118
119 void
120 FillBuffer(const TPixel & value) override;
121
122 void
123 SetPixel(const IndexType & index, const TPixel & value) override;
124
125 const TPixel &
126 GetPixel(const IndexType & index) const override;
127
128 TPixel &
129 GetPixel(const IndexType & index) override;
130
131 TPixel *
133
134 const TPixel *
135 GetBufferPointer() const override;
136
139
140 const PixelContainer *
141 GetPixelContainer() const override;
142
143 void
144 SetPixelContainer(PixelContainer * container) override;
145
148
149 const AccessorType
150 GetPixelAccessor() const override;
151
152 void
153 SetSpacing(const SpacingType & spacing) override;
154
155 void
156 SetOrigin(const PointType & origin) override;
157
159 GetSpacing() override;
160
162 GetOrigin() override;
163
165
166 void
167 CopyInformation(const DataObject * data) override;
168
169 const OffsetValueType *
170 GetOffsetTable() const override;
171
173 ComputeOffset(const IndexType & ind) const override;
174
176 ComputeIndex(OffsetValueType offset) const override;
177
179
181 unsigned int
182 ImageDimension() override;
183
184 unsigned int
186
188 itkGetModifiableObjectMacro(Image, DataObject);
189 itkGetModifiableObjectMacro(Writer, ProcessObject);
190 itkGetModifiableObjectMacro(Reader, ProcessObject);
191
193 void
194 Write() override;
195
197 void
198 Read() override;
199
201 void
202 CreateNewImage() override;
203
204 void
206
209
210 void
212
215
217 void
218 SetOutputFileName(const char * name) override;
219
220 void
221 SetInputFileName(const char * name) override;
222
223 const char *
225
226 const char *
228
229protected:
230 NDImageTemplate() = default;
231 ~NDImageTemplate() override = default;
232
233 // virtual void PrintSelf(std::ostream& os, Indent indent) const;
234
235private:
239
240 template <typename TIn, typename TOut>
241 static TOut
242 ConvertToDynamicArray(const TIn & in)
243 {
244 static_assert(TIn().size() == VDimension);
245 static_assert(std::is_same_v<decltype(TIn().data()), typename TOut::ValueType *>);
246
247 return TOut(in.data(), VDimension);
248 }
249
250 template <typename TIn, typename TOut>
251 static TOut
252 ConvertToStaticArray(const TIn & in)
253 {
254 // Note: It is assumed here that `in.size()` is also equal to VDimension.
255 static_assert(TOut().size() == VDimension);
256 static_assert(std::is_same_v<decltype(*(TIn().begin())), decltype(*(TOut().begin()))>);
257
258 TOut out;
259 std::copy_n(in.begin(), VDimension, out.begin());
260 return out;
261 }
262};
263
264} // end namespace itk
265
266#ifndef ITK_MANUAL_INSTANTIATION
267# include "itkNDImageTemplate.hxx"
268#endif
269
270#endif // end #ifndef itkNDImageTemplate_h
typename Spacing2DType::ValueType SpacingValueType
Array< IndexValueType > IndexType
Array< SizeValueType > SizeType
typename ImageBase< 2 >::OffsetValueType OffsetValueType
typename Image< TPixel, 2 >::PixelContainer PixelContainer
Array< OffsetValueType > OffsetType
Array< PointValueType > PointType
typename Image< TPixel, 2 >::PixelContainerConstPointer PixelContainerConstPointer
Array< SpacingValueType > SpacingType
typename Image< TPixel, 2 >::AccessorType AccessorType
NDImageBase()=default
typename Image< TPixel, 2 >::InternalPixelType InternalPixelType
typename Point2DType::ValueType PointValueType
typename Image< TPixel, 2 >::ValueType ValueType
DataObject::Pointer DataObjectPointer
typename Image< TPixel, 2 >::PixelContainerPointer PixelContainerPointer
IndexType ComputeIndex(OffsetValueType offset) const override
PointType GetOrigin() override
itkOverrideGetNameOfClassMacro(NDImageTemplate)
typename ImageType::SpacingType SpacingTypeD
itkGetModifiableObjectMacro(Image, DataObject)
const TPixel * GetBufferPointer() const override
Array< IndexValueType > IndexType
Array< SizeValueType > SizeType
void SetImageIOWriter(ImageIOBase *_arg) override
void SetOrigin(const PointType &origin) override
void SetOutputFileName(const char *name) override
PixelContainer * GetPixelContainer() override
typename ReaderType::Pointer ReaderPointer
void Write() override
void FillBuffer(const TPixel &value) override
itkStaticConstMacro(Dimension, unsigned int, VDimension)
typename ImageBase< 2 >::OffsetValueType OffsetValueType
typename Image< TPixel, 2 >::PixelContainer PixelContainer
typename ImageType::PointType PointTypeD
const TPixel & GetPixel(const IndexType &index) const override
TPixel & GetPixel(const IndexType &index) override
void SetRegions(SizeType size) override
ITK_DISALLOW_COPY_AND_MOVE(NDImageTemplate)
~NDImageTemplate() override=default
void SetPixel(const IndexType &index, const TPixel &value) override
typename ImageType::Pointer ImagePointer
itkGetModifiableObjectMacro(Writer, ProcessObject)
itkGetModifiableObjectMacro(Reader, ProcessObject)
Array< PointValueType > PointType
const OffsetValueType * GetOffsetTable() const override
void Initialize() override
AccessorType GetPixelAccessor() override
Image< TPixel, VDimension > ImageType
ImageIOBase * GetImageIOReader() override
typename ImageType::IndexType IndexTypeD
const PixelContainer * GetPixelContainer() const override
void SetInputFileName(const char *name) override
ImageFileWriter< ImageType > WriterType
void Allocate() override
typename WriterType::Pointer WriterPointer
const char * GetOutputFileName() override
void CreateNewImage() override
NDImageTemplate()=default
Array< SpacingValueType > SpacingType
typename Image< TPixel, 2 >::AccessorType AccessorType
SmartPointer< Self > Pointer
void SetRequestedRegion(DataObject *data) override
const AccessorType GetPixelAccessor() const override
ImageFileReader< ImageType > ReaderType
NDImageBase< TPixel > Superclass
unsigned int GetImageDimension() override
static TOut ConvertToDynamicArray(const TIn &in)
SmartPointer< const Self > ConstPointer
void SetPixelContainer(PixelContainer *container) override
void Read() override
unsigned int ImageDimension() override
void SetImageIOReader(ImageIOBase *_arg) override
SpacingType GetSpacing() override
TPixel * GetBufferPointer() override
void SetSpacing(const SpacingType &spacing) override
typename ImageType::OffsetType OffsetTypeD
static TOut ConvertToStaticArray(const TIn &in)
ImageIOBase * GetImageIOWriter() override
typename ImageType::SizeType SizeTypeD
const char * GetInputFileName() override
void CopyInformation(const DataObject *data) override
OffsetValueType ComputeOffset(const IndexType &ind) const override


Generated on 1774142652 for elastix by doxygen 1.15.0 elastix logo