ITK  4.3.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 {
79 template< class TPixel, unsigned int VImageDimension = 2 >
80 class ITK_EXPORT Image:public ImageBase< VImageDimension >
81 {
82 public:
84  typedef Image Self;
89 
91  itkNewMacro(Self);
92 
94  itkTypeMacro(Image, ImageBase);
95 
98  typedef TPixel PixelType;
99 
101  typedef TPixel ValueType;
102 
107  typedef TPixel InternalPixelType;
108 
110 
115 
119 
124  itkStaticConstMacro(ImageDimension, unsigned int, VImageDimension);
125 
127  typedef typename Superclass::IndexType IndexType;
129 
131  typedef typename Superclass::OffsetType OffsetType;
132 
134  typedef typename Superclass::SizeType SizeType;
136 
139 
141  typedef typename Superclass::DirectionType DirectionType;
142 
145  typedef typename Superclass::RegionType RegionType;
146 
149  typedef typename Superclass::SpacingType SpacingType;
150  typedef typename Superclass::SpacingValueType SpacingValueType;
151 
154  typedef typename Superclass::PointType PointType;
155 
159 
162 
168  template <class UPixelType, unsigned int UImageDimension = VImageDimension>
169  struct Rebind
170  {
172  };
173 
174 
177  void Allocate();
178 
181  virtual void Initialize();
182 
185  void FillBuffer(const TPixel & value);
186 
192  void SetPixel(const IndexType & index, const TPixel & value)
193  {
194  OffsetValueType offset = this->ComputeOffset(index);
195  ( *m_Buffer )[offset] = value;
196  }
197 
202  const TPixel & GetPixel(const IndexType & index) const
203  {
204  OffsetValueType offset = this->ComputeOffset(index);
205  return ( ( *m_Buffer )[offset] );
206  }
207 
212  TPixel & GetPixel(const IndexType & index)
213  {
214  OffsetValueType offset = this->ComputeOffset(index);
215  return ( ( *m_Buffer )[offset] );
216  }
217 
222  TPixel & operator[](const IndexType & index)
223  { return this->GetPixel(index); }
224 
229  const TPixel & operator[](const IndexType & index) const
230  { return this->GetPixel(index); }
231 
234  virtual TPixel * GetBufferPointer()
235  { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
236  virtual const TPixel * GetBufferPointer() const
237  { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
239 
241  PixelContainer * GetPixelContainer()
242  { return m_Buffer.GetPointer(); }
243 
244  const PixelContainer * GetPixelContainer() const
245  { return m_Buffer.GetPointer(); }
246 
249  void SetPixelContainer(PixelContainer *container);
250 
261  virtual void Graft(const DataObject *data);
262 
264  AccessorType GetPixelAccessor(void)
265  { return AccessorType(); }
266 
268  const AccessorType GetPixelAccessor(void) const
269  { return AccessorType(); }
270 
272  NeighborhoodAccessorFunctorType GetNeighborhoodAccessor()
273  { return NeighborhoodAccessorFunctorType(); }
274 
276  const NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() const
277  { return NeighborhoodAccessorFunctorType(); }
278 
279  virtual unsigned int GetNumberOfComponentsPerPixel() const;
280 
281 protected:
282  Image();
283  void PrintSelf(std::ostream & os, Indent indent) const;
284 
285  virtual ~Image() {}
286 
292  virtual void ComputeIndexToPhysicalPointMatrices();
293 
294 private:
295  Image(const Self &); //purposely not implemented
296  void operator=(const Self &); //purposely not implemented
297 
300 };
301 } // end namespace itk
302 
303 #ifndef ITK_MANUAL_INSTANTIATION
304 #include "itkImage.hxx"
305 #endif
306 
307 #endif
308