ITK  4.8.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 
119  itkStaticConstMacro(ImageDimension, unsigned int, VImageDimension);
120 
124 
127 
129  typedef typename Superclass::SizeType SizeType;
131 
134 
137 
141 
146 
150 
154 
157 
163  template <typename UPixelType, unsigned int UImageDimension = VImageDimension>
164  struct Rebind
165  {
167  };
168 
169 
172  virtual void Allocate(bool initializePixels = false) ITK_OVERRIDE;
173 
176  virtual void Initialize() ITK_OVERRIDE;
177 
180  void FillBuffer(const TPixel & value);
181 
187  void SetPixel(const IndexType & index, const TPixel & value)
188  {
189  OffsetValueType offset = this->ComputeOffset(index);
190  ( *m_Buffer )[offset] = value;
191  }
192 
197  const TPixel & GetPixel(const IndexType & index) const
198  {
199  OffsetValueType offset = this->ComputeOffset(index);
200  return ( ( *m_Buffer )[offset] );
201  }
202 
207  TPixel & GetPixel(const IndexType & index)
208  {
209  OffsetValueType offset = this->ComputeOffset(index);
210  return ( ( *m_Buffer )[offset] );
211  }
212 
217  TPixel & operator[](const IndexType & index)
218  { return this->GetPixel(index); }
219 
224  const TPixel & operator[](const IndexType & index) const
225  { return this->GetPixel(index); }
226 
229  virtual TPixel * GetBufferPointer()
230  { return m_Buffer ? m_Buffer->GetBufferPointer() : ITK_NULLPTR; }
231  virtual const TPixel * GetBufferPointer() const
232  { return m_Buffer ? m_Buffer->GetBufferPointer() : ITK_NULLPTR; }
234 
237  { return m_Buffer.GetPointer(); }
238 
240  { return m_Buffer.GetPointer(); }
241 
244  void SetPixelContainer(PixelContainer *container);
245 
256  virtual void Graft(const DataObject *data) ITK_OVERRIDE;
257 
260  { return AccessorType(); }
261 
263  const AccessorType GetPixelAccessor(void) const
264  { return AccessorType(); }
265 
268  { return NeighborhoodAccessorFunctorType(); }
269 
272  { return NeighborhoodAccessorFunctorType(); }
273 
274  virtual unsigned int GetNumberOfComponentsPerPixel() const ITK_OVERRIDE;
275 
276 protected:
277  Image();
278  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
279 
280  virtual ~Image() {}
281 
287  virtual void ComputeIndexToPhysicalPointMatrices() ITK_OVERRIDE;
288 
289 private:
290  Image(const Self &); //purposely not implemented
291  void operator=(const Self &); //purposely not implemented
292 
295 };
296 } // end namespace itk
297 
298 #ifndef ITK_MANUAL_INSTANTIATION
299 #include "itkImage.hxx"
300 #endif
301 
302 #endif
Superclass::RegionType RegionType
Definition: itkImage.h:140
Index< VImageDimension > IndexType
Definition: itkImageBase.h:134
Superclass::OffsetType OffsetType
Definition: itkImage.h:126
SmartPointer< Self > Pointer
Definition: itkImage.h:81
const PixelContainer * GetPixelContainer() const
Definition: itkImage.h:239
Superclass::SizeValueType SizeValueType
Definition: itkImage.h:130
Superclass::PointType PointType
Definition: itkImage.h:149
TPixel InternalPixelType
Definition: itkImage.h:102
void FillBuffer(const TPixel &value)
virtual TPixel * GetBufferPointer()
Definition: itkImage.h:229
TPixel & GetPixel(const IndexType &index)
Get a reference to a pixel (e.g. for editing).
Definition: itkImage.h:207
SpacePrecisionType SpacingValueType
Definition: itkImageBase.h:153
const TPixel & GetPixel(const IndexType &index) const
Get a pixel (read only version).
Definition: itkImage.h:197
Superclass::IndexValueType IndexValueType
Definition: itkImage.h:123
Superclass::OffsetValueType OffsetValueType
Definition: itkImage.h:156
ObjectType * GetPointer() const
Implements a weak reference to an object.
Superclass::SpacingType SpacingType
Definition: itkImage.h:144
TPixel ValueType
Definition: itkImage.h:96
const AccessorType GetPixelAccessor(void) const
Definition: itkImage.h:263
Size< VImageDimension > SizeType
Definition: itkImageBase.h:143
TPixel PixelType
Definition: itkImage.h:89
Point< PointValueType, VImageDimension > PointType
Definition: itkImageBase.h:159
void PrintSelf(std::ostream &os, Indent indent) const override
const NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() const
Definition: itkImage.h:271
Matrix< SpacePrecisionType, VImageDimension, VImageDimension > DirectionType
Definition: itkImageBase.h:164
SmartPointer< const Self > ConstPointer
Definition: itkImage.h:82
PixelType IOPixelType
Definition: itkImage.h:104
NeighborhoodAccessorFunctorType GetNeighborhoodAccessor()
Definition: itkImage.h:267
NeighborhoodAccessorFunctor< Self > NeighborhoodAccessorFunctorType
Definition: itkImage.h:113
PixelContainer::ConstPointer PixelContainerConstPointer
Definition: itkImage.h:153
WeakPointer< const Self > ConstWeakPointer
Definition: itkImage.h:83
Superclass::SpacingValueType SpacingValueType
Definition: itkImage.h:145
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:139
PixelContainer::Pointer PixelContainerPointer
Definition: itkImage.h:152
Vector< SpacingValueType, VImageDimension > SpacingType
Definition: itkImageBase.h:154
Superclass::IndexType IndexType
Definition: itkImage.h:122
Superclass::SizeType SizeType
Definition: itkImage.h:129
virtual void Graft(const DataObject *data) override
virtual void ComputeIndexToPhysicalPointMatrices() override
virtual void Initialize() override
Superclass::DirectionType DirectionType
Definition: itkImage.h:136
Provides a common API for pixel accessors for Image and VectorImage.
ImportImageContainer< SizeValueType, PixelType > PixelContainer
Definition: itkImage.h:133
itk::Image< UPixelType, UImageDimension > Type
Definition: itkImage.h:166
PixelContainerPointer m_Buffer
Definition: itkImage.h:294
virtual const TPixel * GetBufferPointer() const
Definition: itkImage.h:231
SizeType::SizeValueType SizeValueType
Definition: itkImageBase.h:144
OffsetType::OffsetValueType OffsetValueType
Definition: itkImageBase.h:140
Image Self
Definition: itkImage.h:79
Base class for templated image classes.
Definition: itkImageBase.h:112
static const unsigned int ImageDimension
Definition: itkImage.h:119
AccessorType GetPixelAccessor(void)
Definition: itkImage.h:259
DefaultPixelAccessor< PixelType > AccessorType
Definition: itkImage.h:108
Control indentation during Print() invocation.
Definition: itkIndent.h:49
PixelContainer * GetPixelContainer()
Definition: itkImage.h:236
const TPixel & operator[](const IndexType &index) const
Access a pixel. This version can only be an rvalue.
Definition: itkImage.h:224
OffsetValueType ComputeOffset(const IndexType &ind) const
Definition: itkImageBase.h:332
void SetPixelContainer(PixelContainer *container)
ImageRegion< VImageDimension > RegionType
Definition: itkImageBase.h:147
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:217
virtual void Allocate(bool initializePixels=false) override
void SetPixel(const IndexType &index, const TPixel &value)
Set a pixel value.
Definition: itkImage.h:187
Base class for all data objects in ITK.
IndexType::IndexValueType IndexValueType
Definition: itkImageBase.h:135
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.