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 OffsetValueType = typename ImageBase<2>::OffsetValueType;
94
100 using IndexType = Array<IndexValueType>;
101 using SizeType = Array<SizeValueType>;
102 using SpacingType = Array<SpacingValueType>;
103 using PointType = Array<PointValueType>;
104 using OffsetType = Array<OffsetValueType>;
109 // using typename Superclass::RegionType;
110
119 // void SetRegions(RegionType region) = 0;
120 virtual void
122
123 virtual void
124 SetRequestedRegion(DataObject * data) = 0;
125
126 virtual void
127 Allocate() = 0;
128
129 virtual void
131
132 virtual void
133 FillBuffer(const TPixel & value) = 0;
134
135 virtual void
136 SetPixel(const IndexType & index, const TPixel & value) = 0;
137
138 virtual const TPixel &
139 GetPixel(const IndexType & index) const = 0;
140
141 virtual TPixel &
142 GetPixel(const IndexType & index) = 0;
143
144 TPixel & operator[](const IndexType & index) { return this->GetPixel(index); }
145 const TPixel & operator[](const IndexType & index) const { return this->GetPixel(index); }
146
147 virtual TPixel *
149
150 virtual const TPixel *
151 GetBufferPointer() const = 0;
152
153 virtual PixelContainer *
155
156 virtual const PixelContainer *
157 GetPixelContainer() const = 0;
158
159 virtual void
161
162 virtual AccessorType
164
165 virtual const AccessorType
166 GetPixelAccessor() const = 0;
167
168 virtual void
169 SetSpacing(const SpacingType & spacing) = 0;
170
171 virtual void
172 SetOrigin(const PointType & origin) = 0;
173
174 /* Get Spacing/Origin return copies; not a const &, like
175 * itkImage; necessary because of the conversion to arrays */
176 virtual SpacingType
178
179 virtual PointType
181
184 virtual void
185 CopyInformation(const DataObject * data) = 0;
186
187 virtual const OffsetValueType *
188 GetOffsetTable() const = 0;
189
190 virtual OffsetValueType
191 ComputeOffset(const IndexType & ind) const = 0;
192
193 virtual IndexType
194 ComputeIndex(OffsetValueType offset) const = 0;
195
199 virtual unsigned int
201
202 virtual unsigned int
204
205 virtual void
207
208 virtual ImageIOBase *
210
211 virtual void
213
214 virtual ImageIOBase *
216
218 virtual void
219 Write() = 0;
220
222 virtual void
223 Read() = 0;
224
226 virtual void
228
230 virtual void
231 SetOutputFileName(const char *) = 0;
232
233 virtual void
234 SetInputFileName(const char *) = 0;
235
236 virtual const char *
238
239 virtual const char *
241
242 static Pointer
243 NewNDImage(unsigned int dim);
244
245protected:
246 NDImageBase() = default;
247 ~NDImageBase() override = default;
248
249 // virtual void PrintSelf(std::ostream& os, Indent indent) const = 0;
250};
251
252} // end namespace itk
253
254#include "itkNDImageTemplate.h"
255
256namespace itk
257{
258
259template <class TPixel>
260auto
262{
263 switch (dim)
264 {
265 case 1:
266 return dynamic_cast<NDImageBase<TPixel> *>(NDImageTemplate<TPixel, 1>::New().GetPointer());
267 case 2:
268 return dynamic_cast<NDImageBase<TPixel> *>(NDImageTemplate<TPixel, 2>::New().GetPointer());
269 case 3:
270 return dynamic_cast<NDImageBase<TPixel> *>(NDImageTemplate<TPixel, 3>::New().GetPointer());
271 case 4:
272 return dynamic_cast<NDImageBase<TPixel> *>(NDImageTemplate<TPixel, 4>::New().GetPointer());
273 case 5:
274 return dynamic_cast<NDImageBase<TPixel> *>(NDImageTemplate<TPixel, 5>::New().GetPointer());
275 // add here more dimensions if needed...
276 // we could do this also with a recursive
277 // template and a #define MAXDIM,
278 // or something like that....
279 default:
280 // Return a default-constructed SmartPointer (null).
281 return typename NDImageBase<TPixel>::Pointer();
282 }
283}
284
285
286} // end namespace itk
287
288#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
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
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 2024-07-17 for elastix by doxygen 1.11.0 (9b424b03c9833626cd435af22a444888fbbb192d) elastix logo