ITK  4.9.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 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 
117 
121 
124 
126  typedef typename Superclass::SizeType SizeType;
128 
131 
134 
138 
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 DataObject *data) ITK_OVERRIDE;
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 
277  virtual ~Image() {}
278 
284  virtual void ComputeIndexToPhysicalPointMatrices() ITK_OVERRIDE;
285 
286 private:
287  Image(const Self &) ITK_DELETE_FUNCTION;
288  void operator=(const Self &) ITK_DELETE_FUNCTION;
289 
292 };
293 } // end namespace itk
294 
295 #ifndef ITK_MANUAL_INSTANTIATION
296 #include "itkImage.hxx"
297 #endif
298 
299 #endif
itk::Image< UPixelType, NUImageDimension > Type
Definition: itkImage.h:163
Superclass::RegionType RegionType
Definition: itkImage.h:137
Index< VImageDimension > IndexType
Definition: itkImageBase.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
Superclass::PointType PointType
Definition: itkImage.h:146
TPixel InternalPixelType
Definition: itkImage.h:102
void FillBuffer(const TPixel &value)
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
SpacePrecisionType SpacingValueType
Definition: itkImageBase.h:156
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
ObjectType * GetPointer() const
Implements a weak reference to an object.
Superclass::SpacingType SpacingType
Definition: itkImage.h:141
TPixel ValueType
Definition: itkImage.h:96
const AccessorType GetPixelAccessor(void) const
Definition: itkImage.h:260
Size< VImageDimension > SizeType
Definition: itkImageBase.h:146
TPixel PixelType
Definition: itkImage.h:89
Point< PointValueType, VImageDimension > PointType
Definition: itkImageBase.h:162
void PrintSelf(std::ostream &os, Indent indent) const override
const NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() const
Definition: itkImage.h:268
Matrix< SpacePrecisionType, VImageDimension, VImageDimension > DirectionType
Definition: itkImageBase.h:167
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
unsigned int ImageDimensionType
Definition: itkImageBase.h:125
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...
Offset< VImageDimension > OffsetType
Definition: itkImageBase.h:142
PixelContainer::Pointer PixelContainerPointer
Definition: itkImage.h:149
Vector< SpacingValueType, VImageDimension > SpacingType
Definition: itkImageBase.h:157
Superclass::IndexType IndexType
Definition: itkImage.h:119
OffsetValueType FastComputeOffset(const IndexType &ind) const
Definition: itkImageBase.h:731
Superclass::SizeType SizeType
Definition: itkImage.h:126
virtual void Graft(const DataObject *data) override
virtual void ComputeIndexToPhysicalPointMatrices() override
virtual void Initialize() override
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
PixelContainerPointer m_Buffer
Definition: itkImage.h:291
Superclass::ImageDimensionType ImageDimensionType
Definition: itkImage.h:116
virtual const TPixel * GetBufferPointer() const
Definition: itkImage.h:228
SizeType::SizeValueType SizeValueType
Definition: itkImageBase.h:147
OffsetType::OffsetValueType OffsetValueType
Definition: itkImageBase.h:143
Image Self
Definition: itkImage.h:79
Base class for templated image classes.
Definition: itkImageBase.h:112
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
void SetPixelContainer(PixelContainer *container)
ImageRegion< VImageDimension > RegionType
Definition: itkImageBase.h:150
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
virtual void Allocate(bool initializePixels=false) override
void SetPixel(const IndexType &index, const TPixel &value)
Set a pixel value.
Definition: itkImage.h:184
Base class for all data objects in ITK.
IndexType::IndexValueType IndexValueType
Definition: itkImageBase.h:138
Templated n-dimensional image class.
Definition: itkImage.h:75
virtual unsigned int GetNumberOfComponentsPerPixel() const override
Defines an itk::Image front-end to a standard C-array.