00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
#ifndef __itkImageAdaptor_h
00018
#define __itkImageAdaptor_h
00019
00020
#include "itkImage.h"
00021
00022
namespace itk
00023 {
00024
00046
template <
class TImage,
class TAccessor >
00047 class ITK_EXPORT ImageAdaptor :
public ImageBase< ::itk::GetImageDimension<TImage>::ImageDimension>
00048 {
00049
public:
00054
itkStaticConstMacro(ImageDimension,
unsigned int, TImage::ImageDimension);
00055
00057
typedef ImageAdaptor
Self;
00058 typedef ImageBase<itkGetStaticConstMacro(ImageDimension)> Superclass;
00059 typedef SmartPointer<Self> Pointer;
00060 typedef SmartPointer<const Self> ConstPointer;
00061
00063
itkTypeMacro(ImageAdaptor,
ImageBase);
00064
00066
typedef TImage
InternalImageType;
00067
00069
itkNewMacro(
Self);
00070
00073
typedef typename TAccessor::ExternalType
PixelType;
00074
00077
typedef typename TAccessor::InternalType
InternalPixelType;
00078
00081
typedef TAccessor
AccessorType;
00082
00084
typedef Index<itkGetStaticConstMacro(ImageDimension)> IndexType;
00085 typedef typename IndexType::IndexValueType
IndexValueType;
00086
00088
typedef Size<itkGetStaticConstMacro(ImageDimension)> SizeType;
00089 typedef typename SizeType::SizeValueType
SizeValueType;
00090
00092
typedef Offset<itkGetStaticConstMacro(ImageDimension)> OffsetType;
00093 typedef typename OffsetType::OffsetValueType
OffsetValueType;
00094
00097
typedef ImageRegion<itkGetStaticConstMacro(ImageDimension)> RegionType;
00098
00105
virtual void SetLargestPossibleRegion(
const RegionType ®ion);
00106
00110
virtual void SetBufferedRegion(
const RegionType ®ion);
00111
00115
virtual void SetRequestedRegion(
const RegionType ®ion);
00116
00121
virtual void SetRequestedRegion(
DataObject *data);
00122
00129
virtual const RegionType & GetRequestedRegion() const;
00130
00139 virtual const
RegionType& GetLargestPossibleRegion() const;
00140
00146 virtual const
RegionType& GetBufferedRegion() const;
00147
00149 inline
void Allocate();
00150
00151
00154 virtual
void Initialize();
00155
00157
void SetPixel(const
IndexType &index, const
PixelType & value)
00158 { m_PixelAccessor.Set( m_Image->GetPixel(index), value ); }
00159
00161 PixelType GetPixel(
const IndexType &index)
const
00162 {
return m_PixelAccessor.Get( m_Image->GetPixel(index) ); }
00163
00165 PixelType operator[](
const IndexType &index)
const
00166 {
return m_PixelAccessor.Get( m_Image->GetPixel(index) ); }
00167
00169
const OffsetValueType *GetOffsetTable() const;
00170
00172 IndexType ComputeIndex(OffsetValueType offset) const;
00173
00176 typedef typename TImage::PixelContainer PixelContainer;
00177 typedef typename TImage::
PixelContainerPointer PixelContainerPointer;
00178
00180 PixelContainerPointer GetPixelContainer()
00181 {
return m_Image->GetPixelContainer(); };
00182
00185
void SetPixelContainer( PixelContainer *container );
00186
00188
typedef InternalPixelType * InternalPixelPointerType;
00189
00192
InternalPixelType *GetBufferPointer();
00193
const InternalPixelType *GetBufferPointer() const;
00194
void GetBufferPointer2(
InternalPixelPointerType & );
00195
00197 virtual
void SetSpacing( const
double values[ImageDimension] );
00198 virtual
void SetSpacing( const
float values[ImageDimension] );
00199
00204 virtual const
double* GetSpacing() const;
00205
00210 virtual const
double * GetOrigin() const;
00211
00213 virtual
void SetOrigin( const
double values[ImageDimension] );
00214 virtual
void SetOrigin( const
float values[ImageDimension] );
00215
00217 virtual
void SetImage( TImage * );
00218
00220 virtual
void Modified() const;
00221
00223 virtual
unsigned long GetMTime() const;
00224
00226
AccessorType & GetPixelAccessor(
void )
00227 {
return m_PixelAccessor; }
00228
00230 const AccessorType & GetPixelAccessor(
void )
const
00231
{
return m_PixelAccessor; }
00232
00234 void SetPixelAccessor(
const AccessorType & accessor )
00235 { m_PixelAccessor = accessor; }
00236
00238 virtual void Update();
00239
virtual void UpdateOutputInformation();
00240
virtual void SetRequestedRegionToLargestPossibleRegion();
00241
virtual void CopyInformation(
const DataObject *data);
00242
00243
protected:
00244 ImageAdaptor();
00245
virtual ~ImageAdaptor();
00246
void PrintSelf(std::ostream& os,
Indent indent)
const;
00247
00248
private:
00249 ImageAdaptor(
const Self&);
00250
void operator=(
const Self&);
00251
00252
00253
00254
typename TImage::Pointer m_Image;
00255
00256
00257
00258
AccessorType m_PixelAccessor;
00259
00260
00261 };
00262
00263 }
00264
00265
#ifndef ITK_MANUAL_INSTANTIATION
00266
#include "itkImageAdaptor.txx"
00267
#endif
00268
00269
00270
00271
#endif
00272