go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkNDImageBase.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
19#ifndef itkNDImageBase_h
20#define itkNDImageBase_h
21
22#include "itkImage.h"
23#include "itkArray.h"
24#include <string>
25#include "itkImageFileWriter.h"
26
27namespace itk
28{
29
57template <class TPixel>
58class ITK_TEMPLATE_EXPORT NDImageBase : public Object
59{
60public:
62
65 using Superclass = Object;
66 using Pointer = SmartPointer<Self>;
67 using ConstPointer = SmartPointer<const Self>;
68
70 // itkNewMacro( Self );
71 // not declared, because instantiating an object of this
72 // (abstract) type makes no sense.
73
75 itkTypeMacro(NDImageBase, Object);
76
77 using DataObjectPointer = DataObject::Pointer;
78
80 using PixelType = typename Image<TPixel, 2>::PixelType;
87
88 using Spacing2DType = typename ImageBase<2>::SpacingType;
89 using Point2DType = typename ImageBase<2>::PointType;
90
91 using SpacingValueType = typename Spacing2DType::ValueType;
92 using PointValueType = typename Point2DType::ValueType;
93 using IndexValueType = typename ImageBase<2>::IndexValueType;
94 using SizeValueType = typename ImageBase<2>::SizeValueType;
95 using OffsetValueType = typename ImageBase<2>::OffsetValueType;
96
102 using IndexType = Array<IndexValueType>;
103 using SizeType = Array<SizeValueType>;
104 using SpacingType = Array<SpacingValueType>;
105 using PointType = Array<PointValueType>;
106 using OffsetType = Array<OffsetValueType>;
111 // using typename Superclass::RegionType;
112
121 // void SetRegions(RegionType region) = 0;
122 virtual void
124
125 virtual void
126 SetRequestedRegion(DataObject * data) = 0;
127
128 virtual void
129 Allocate() = 0;
130
131 virtual void
133
134 virtual void
135 FillBuffer(const TPixel & value) = 0;
136
137 virtual void
138 SetPixel(const IndexType & index, const TPixel & value) = 0;
139
140 virtual const TPixel &
141 GetPixel(const IndexType & index) const = 0;
142
143 virtual TPixel &
144 GetPixel(const IndexType & index) = 0;
145
146 TPixel & operator[](const IndexType & index) { return this->GetPixel(index); }
147 const TPixel & operator[](const IndexType & index) const { return this->GetPixel(index); }
148
149 virtual TPixel *
151
152 virtual const TPixel *
153 GetBufferPointer() const = 0;
154
155 virtual PixelContainer *
157
158 virtual const PixelContainer *
159 GetPixelContainer() const = 0;
160
161 virtual void
163
164 virtual AccessorType
166
167 virtual const AccessorType
168 GetPixelAccessor() const = 0;
169
170 virtual void
171 SetSpacing(const SpacingType & spacing) = 0;
172
173 virtual void
174 SetOrigin(const PointType & origin) = 0;
175
176 /* Get Spacing/Origin return copies; not a const &, like
177 * itkImage; necessary because of the conversion to arrays */
178 virtual SpacingType
180
181 virtual PointType
183
186 virtual void
187 CopyInformation(const DataObject * data) = 0;
188
189 virtual const OffsetValueType *
190 GetOffsetTable() const = 0;
191
192 virtual OffsetValueType
193 ComputeOffset(const IndexType & ind) const = 0;
194
195 virtual IndexType
196 ComputeIndex(OffsetValueType offset) const = 0;
197
201 virtual unsigned int
203
204 virtual unsigned int
206
207 virtual void
209
210 virtual ImageIOBase *
212
213 virtual void
215
216 virtual ImageIOBase *
218
220 virtual void
221 Write() = 0;
222
224 virtual void
225 Read() = 0;
226
228 virtual void
230
232 virtual void
233 SetOutputFileName(const char *) = 0;
234
235 virtual void
236 SetInputFileName(const char *) = 0;
237
238 virtual const char *
240
241 virtual const char *
243
244 static Pointer
245 NewNDImage(unsigned int dim);
246
247protected:
248 NDImageBase() = default;
249 ~NDImageBase() override = default;
250
251 // virtual void PrintSelf(std::ostream& os, Indent indent) const = 0;
252};
253
254} // end namespace itk
255
256#include "itkNDImageTemplate.h"
257
258namespace itk
259{
260
261template <class TPixel>
262auto
264{
265 switch (dim)
266 {
267 case 1:
268 return dynamic_cast<NDImageBase<TPixel> *>(NDImageTemplate<TPixel, 1>::New().GetPointer());
269 case 2:
270 return dynamic_cast<NDImageBase<TPixel> *>(NDImageTemplate<TPixel, 2>::New().GetPointer());
271 case 3:
272 return dynamic_cast<NDImageBase<TPixel> *>(NDImageTemplate<TPixel, 3>::New().GetPointer());
273 case 4:
274 return dynamic_cast<NDImageBase<TPixel> *>(NDImageTemplate<TPixel, 4>::New().GetPointer());
275 case 5:
276 return dynamic_cast<NDImageBase<TPixel> *>(NDImageTemplate<TPixel, 5>::New().GetPointer());
277 // add here more dimensions if needed...
278 // we could do this also with a recursive
279 // template and a #define MAXDIM,
280 // or something like that....
281 default:
282 // Return a default-constructed SmartPointer (null).
283 return typename NDImageBase<TPixel>::Pointer();
284 }
285}
286
287
288} // end namespace itk
289
290#endif // end #ifndef itkNDImageBase_h
An image whose dimension can be specified at runtime.
virtual void Initialize()=0
typename Spacing2DType::ValueType SpacingValueType
virtual void Allocate()=0
virtual const TPixel * GetBufferPointer() const =0
Array< IndexValueType > IndexType
Array< SizeValueType > SizeType
virtual void SetSpacing(const SpacingType &spacing)=0
const TPixel & operator[](const IndexType &index) const
static Pointer NewNDImage(unsigned int dim)
virtual void CreateNewImage()=0
virtual void FillBuffer(const TPixel &value)=0
virtual void Read()=0
typename ImageBase< 2 >::OffsetValueType OffsetValueType
virtual void SetImageIOWriter(ImageIOBase *_arg)=0
typename Image< TPixel, 2 >::PixelContainer PixelContainer
virtual TPixel & GetPixel(const IndexType &index)=0
virtual void CopyInformation(const DataObject *data)=0
virtual const TPixel & GetPixel(const IndexType &index) const =0
SmartPointer< const Self > ConstPointer
~NDImageBase() override=default
virtual unsigned int ImageDimension()=0
virtual OffsetValueType ComputeOffset(const IndexType &ind) const =0
typename ImageBase< 2 >::PointType Point2DType
Array< OffsetValueType > OffsetType
virtual void SetInputFileName(const char *)=0
virtual void SetRequestedRegion(DataObject *data)=0
virtual const OffsetValueType * GetOffsetTable() const =0
Array< PointValueType > PointType
typename ImageBase< 2 >::SizeValueType SizeValueType
virtual void SetPixelContainer(PixelContainer *container)=0
virtual IndexType ComputeIndex(OffsetValueType offset) const =0
typename Image< TPixel, 2 >::PixelContainerConstPointer PixelContainerConstPointer
virtual PointType GetOrigin()=0
virtual const AccessorType GetPixelAccessor() const =0
virtual SpacingType GetSpacing()=0
virtual void SetImageIOReader(ImageIOBase *_arg)=0
virtual PixelContainer * GetPixelContainer()=0
virtual unsigned int GetImageDimension()=0
virtual const char * GetOutputFileName()=0
typename ImageBase< 2 >::SpacingType Spacing2DType
Array< SpacingValueType > SpacingType
typename Image< TPixel, 2 >::AccessorType AccessorType
virtual TPixel * GetBufferPointer()=0
virtual void SetOutputFileName(const char *)=0
ITK_DISALLOW_COPY_AND_MOVE(NDImageBase)
virtual ImageIOBase * GetImageIOReader()=0
NDImageBase()=default
typename Image< TPixel, 2 >::InternalPixelType InternalPixelType
typename Point2DType::ValueType PointValueType
SmartPointer< Self > Pointer
virtual void SetPixel(const IndexType &index, const TPixel &value)=0
virtual ImageIOBase * GetImageIOWriter()=0
virtual AccessorType GetPixelAccessor()=0
TPixel & operator[](const IndexType &index)
virtual const PixelContainer * GetPixelContainer() const =0
typename Image< TPixel, 2 >::ValueType ValueType
DataObject::Pointer DataObjectPointer
typename ImageBase< 2 >::IndexValueType IndexValueType
virtual void SetRegions(SizeType size)=0
virtual void SetOrigin(const PointType &origin)=0
virtual const char * GetInputFileName()=0
virtual void Write()=0
typename Image< TPixel, 2 >::PixelContainerPointer PixelContainerPointer
static Pointer New()


Generated on 2023-01-13 for elastix by doxygen 1.9.6 elastix logo