ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkImage.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software 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  * 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 itkImage_h
19 #define itkImage_h
20 
21 #include "itkImageRegion.h"
25 #include "itkPoint.h"
26 #include "itkFixedArray.h"
27 #include "itkWeakPointer.h"
29 
30 namespace itk
31 {
74 template< typename TPixel, unsigned int VImageDimension = 2 >
75 class ITK_TEMPLATE_EXPORT Image:public ImageBase< VImageDimension >
76 {
77 public:
79  typedef Image Self;
84 
86  itkNewMacro(Self);
87 
89  itkTypeMacro(Image, ImageBase);
90 
93  typedef TPixel PixelType;
94 
96  typedef TPixel ValueType;
97 
102  typedef TPixel InternalPixelType;
103 
105 
110 
114 
116  typedef typename Superclass::ImageDimensionType ImageDimensionType;
117 
121 
123  typedef typename Superclass::OffsetType OffsetType;
124 
126  typedef typename Superclass::SizeType SizeType;
128 
131 
134 
137  typedef typename Superclass::RegionType RegionType;
138 
141  typedef typename Superclass::SpacingType SpacingType;
142  typedef typename Superclass::SpacingValueType SpacingValueType;
143 
147 
151 
154 
160  template <typename UPixelType, unsigned int NUImageDimension = VImageDimension>
161  struct Rebind
162  {
164  };
165 
166 
169  virtual void Allocate(bool initializePixels = false) ITK_OVERRIDE;
170 
173  virtual void Initialize() ITK_OVERRIDE;
174 
177  void FillBuffer(const TPixel & value);
178 
184  void SetPixel(const IndexType & index, const TPixel & value)
185  {
186  OffsetValueType offset = this->FastComputeOffset(index);
187  ( *m_Buffer )[offset] = value;
188  }
189 
194  const TPixel & GetPixel(const IndexType & index) const
195  {
196  OffsetValueType offset = this->FastComputeOffset(index);
197  return ( ( *m_Buffer )[offset] );
198  }
199 
204  TPixel & GetPixel(const IndexType & index)
205  {
206  OffsetValueType offset = this->FastComputeOffset(index);
207  return ( ( *m_Buffer )[offset] );
208  }
209 
214  TPixel & operator[](const IndexType & index)
215  { return this->GetPixel(index); }
216 
221  const TPixel & operator[](const IndexType & index) const
222  { return this->GetPixel(index); }
223 
226  virtual TPixel * GetBufferPointer()
227  { return m_Buffer ? m_Buffer->GetBufferPointer() : ITK_NULLPTR; }
228  virtual const TPixel * GetBufferPointer() const
229  { return m_Buffer ? m_Buffer->GetBufferPointer() : ITK_NULLPTR; }
231 
234  { return m_Buffer.GetPointer(); }
235 
237  { return m_Buffer.GetPointer(); }
238 
241  void SetPixelContainer(PixelContainer *container);
242 
253  virtual void Graft(const Self *data);
254 
257  { return AccessorType(); }
258 
260  const AccessorType GetPixelAccessor(void) const
261  { return AccessorType(); }
262 
265  { return NeighborhoodAccessorFunctorType(); }
266 
269  { return NeighborhoodAccessorFunctorType(); }
270 
271  virtual unsigned int GetNumberOfComponentsPerPixel() const ITK_OVERRIDE;
272 
273 protected:
274  Image();
275  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
276  virtual void Graft(const DataObject *data) ITK_OVERRIDE;
277 
278  virtual ~Image() ITK_OVERRIDE {}
279 
285  virtual void ComputeIndexToPhysicalPointMatrices() ITK_OVERRIDE;
286  using Superclass::Graft;
287 private:
288  ITK_DISALLOW_COPY_AND_ASSIGN(Image);
290 
292  PixelContainerPointer m_Buffer;
293 };
294 } // end namespace itk
295 
296 #ifndef ITK_MANUAL_INSTANTIATION
297 #include "itkImage.hxx"
298 #endif
299 
300 #endif
itk::Image< UPixelType, NUImageDimension > Type
Definition: itkImage.h:163
Superclass::RegionType RegionType
Definition: itkImage.h:137
Superclass::OffsetType OffsetType
Definition: itkImage.h:123
SmartPointer< Self > Pointer
Definition: itkImage.h:81
const PixelContainer * GetPixelContainer() const
Definition: itkImage.h:236
Superclass::SizeValueType SizeValueType
Definition: itkImage.h:127
signed long OffsetValueType
Definition: itkIntTypes.h:154
Superclass::PointType PointType
Definition: itkImage.h:146
TPixel InternalPixelType
Definition: itkImage.h:102
signed long IndexValueType
Definition: itkIntTypes.h:150
virtual TPixel * GetBufferPointer()
Definition: itkImage.h:226
TPixel & GetPixel(const IndexType &index)
Get a reference to a pixel (e.g. for editing).
Definition: itkImage.h:204
const TPixel & GetPixel(const IndexType &index) const
Get a pixel (read only version).
Definition: itkImage.h:194
Superclass::IndexValueType IndexValueType
Definition: itkImage.h:120
Superclass::OffsetValueType OffsetValueType
Definition: itkImage.h:153
Implements a weak reference to an object.
Superclass::SpacingType SpacingType
Definition: itkImage.h:141
TPixel ValueType
Definition: itkImage.h:96
unsigned long SizeValueType
Definition: itkIntTypes.h:143
const AccessorType GetPixelAccessor(void) const
Definition: itkImage.h:260
TPixel PixelType
Definition: itkImage.h:89
const NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() const
Definition: itkImage.h:268
SmartPointer< const Self > ConstPointer
Definition: itkImage.h:82
PixelType IOPixelType
Definition: itkImage.h:104
NeighborhoodAccessorFunctorType GetNeighborhoodAccessor()
Definition: itkImage.h:264
NeighborhoodAccessorFunctor< Self > NeighborhoodAccessorFunctorType
Definition: itkImage.h:113
PixelContainer::ConstPointer PixelContainerConstPointer
Definition: itkImage.h:150
WeakPointer< const Self > ConstWeakPointer
Definition: itkImage.h:83
Superclass::SpacingValueType SpacingValueType
Definition: itkImage.h:142
DefaultPixelAccessorFunctor< Self > AccessorFunctorType
Definition: itkImage.h:109
Provides accessor interfaces to Get pixels and is meant to be used on pointers contained within Neigh...
PixelContainer::Pointer PixelContainerPointer
Definition: itkImage.h:149
Superclass::IndexType IndexType
Definition: itkImage.h:119
Superclass::SizeType SizeType
Definition: itkImage.h:126
Superclass::DirectionType DirectionType
Definition: itkImage.h:133
Provides a common API for pixel accessors for Image and VectorImage.
ImportImageContainer< SizeValueType, PixelType > PixelContainer
Definition: itkImage.h:130
Superclass::ImageDimensionType ImageDimensionType
Definition: itkImage.h:116
virtual const TPixel * GetBufferPointer() const
Definition: itkImage.h:228
OffsetType::OffsetValueType OffsetValueType
Definition: itkImageBase.h:145
Image Self
Definition: itkImage.h:79
Base class for templated image classes.
Definition: itkImageBase.h:114
AccessorType GetPixelAccessor(void)
Definition: itkImage.h:256
DefaultPixelAccessor< PixelType > AccessorType
Definition: itkImage.h:108
Control indentation during Print() invocation.
Definition: itkIndent.h:49
PixelContainer * GetPixelContainer()
Definition: itkImage.h:233
const TPixel & operator[](const IndexType &index) const
Access a pixel. This version can only be an rvalue.
Definition: itkImage.h:221
ImageBase< VImageDimension > Superclass
Definition: itkImage.h:80
Give access to partial aspects a type.
TPixel & operator[](const IndexType &index)
Access a pixel. This version can be an lvalue.
Definition: itkImage.h:214
Base class for all data objects in ITK.
Templated n-dimensional image class.
Definition: itkImage.h:75
Defines an itk::Image front-end to a standard C-array.