| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkVectorImageToImageAdaptor.h.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:49 $ |
| 7 |
|
Version: $Revision: 1.4 $ |
| 8 |
|
|
| 9 |
|
Copyright (c) Insight Software Consortium. All rights reserved. |
| 10 |
|
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. |
| 11 |
|
|
| 12 |
|
This software is distributed WITHOUT ANY WARRANTY; without even |
| 13 |
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 |
|
PURPOSE. See the above copyright notices for more information. |
| 15 |
|
|
| 16 |
|
=========================================================================*/ |
| 17 |
|
#ifndef __itkVectorImageToImageAdaptor_h |
| 18 |
|
#define __itkVectorImageToImageAdaptor_h |
| 19 |
|
|
| 20 |
|
#include "itkImageAdaptor.h" |
| 21 |
|
#include "itkVectorImage.h" |
| 22 |
|
|
| 23 |
|
namespace itk |
| 24 |
|
{ |
| 25 |
|
namespace Accessor |
| 26 |
|
{ |
| 27 |
|
|
| 28 |
|
/** \class VectorImageToImagePixelAccessor |
| 29 |
|
* \brief Extract components from a VectorImage. |
| 30 |
|
* |
| 31 |
|
* This accessor is used to extract components from a VectorImage. It is used |
| 32 |
|
* from VectorImageComponentExtractAdaptor. The component to extract is set |
| 33 |
|
* using SetExtractComponentIdx. |
| 34 |
|
* |
| 35 |
|
* \note |
| 36 |
|
* This work is part of the National Alliance for Medical Image Computing |
| 37 |
|
* (NAMIC), funded by the National Institutes of Health through the NIH Roadmap |
| 38 |
|
* for Medical Research, Grant U54 EB005149. |
| 39 |
|
* |
| 40 |
|
* \ingroup ImageAdaptors |
| 41 |
|
*/ |
| 42 |
|
template <class TType > |
| 43 |
|
class ITK_EXPORT VectorImageToImagePixelAccessor |
| 44 |
|
{ |
| 45 |
|
public: |
| 46 |
|
|
| 47 |
|
typedef unsigned int VectorLengthType; |
| 48 |
|
|
| 49 |
|
/** External typedef. It defines the external aspect |
| 50 |
|
* that this class will exhibit. */ |
| 51 |
|
typedef TType ExternalType; |
| 52 |
|
|
| 53 |
|
/** Internal typedef. It defines the internal real |
| 54 |
|
* representation of data. */ |
| 55 |
|
typedef VariableLengthVector< TType > InternalType; |
| 56 |
|
|
| 57 |
|
/** The pixel type that TInternalContainerType holds */ |
| 58 |
|
typedef TType PixelType; |
| 59 |
|
|
| 60 |
|
inline void Set(InternalType & output, const ExternalType & input) const |
| 61 |
|
{ |
| 62 |
|
output[m_ComponentIdx] = input; |
| 63 |
|
} |
| 64 |
|
|
| 65 |
|
inline ExternalType Get( const InternalType & input ) const |
| 66 |
|
{ |
| 67 |
|
ExternalType output; |
| 68 |
|
output = input[m_ComponentIdx]; |
| 69 |
|
return output; |
| 70 |
|
} |
| 71 |
|
|
| 72 |
|
void SetExtractComponentIdx( VectorLengthType idx ) |
| 73 |
|
{ |
| 74 |
|
m_ComponentIdx = idx; |
| 75 |
|
} |
| 76 |
|
VectorLengthType GetExtractComponentIdx() const |
| 77 |
|
{ |
| 78 |
|
return m_ComponentIdx; |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
VectorImageToImagePixelAccessor() : m_ComponentIdx( 0 ) {}; |
| 82 |
|
virtual ~VectorImageToImagePixelAccessor() {}; |
| 83 |
|
|
| 84 |
|
private: |
| 85 |
|
VectorLengthType m_ComponentIdx; |
| 86 |
|
}; |
| 87 |
|
|
| 88 |
|
} // end namespace Accessor |
| 89 |
|
|
| 90 |
|
|
| 91 |
EML |
|
| 92 |
|
/** \class VectorToRGBImageAdaptor |
| 93 |
|
* \brief Presents a VectorImage and extracts a component from it into an image. |
| 94 |
|
* |
| 95 |
|
* The class is expected to be templated over a pixel type and dimension. These |
| 96 |
|
* are the pixel types and dimension of the VectorImage. |
| 97 |
|
* |
| 98 |
|
* The component to extract is set with SetExtractComponentIdx() method |
| 99 |
|
* RGBPixel type. |
| 100 |
|
* |
| 101 |
|
* \thanks |
| 102 |
|
* This work is part of the National Alliance for Medical Image Computing |
| 103 |
|
* (NAMIC), funded by the National Institutes of Health through the NIH Roadmap |
| 104 |
|
* for Medical Research, Grant U54 EB005149. |
| 105 |
|
* |
| 106 |
|
* \ingroup ImageAdaptors |
| 107 |
|
* |
| 108 |
|
*/ |
| 109 |
|
template<class TPixelType, unsigned int Dimension> |
| 110 |
|
class ITK_EXPORT VectorImageToImageAdaptor : public |
| 111 |
IND |
******ImageAdaptor< VectorImage< TPixelType, Dimension >, |
| 112 |
IND |
********Accessor::VectorImageToImagePixelAccessor< TPixelType > > |
| 113 |
|
{ |
| 114 |
|
public: |
| 115 |
|
/** Standard class typedefs. */ |
| 116 |
|
typedef VectorImageToImageAdaptor Self; |
| 117 |
TDA |
typedef VectorImage< TPixelType, Dimension > VectorImageType; |
| 118 |
|
typedef ImageAdaptor< VectorImageType, |
| 119 |
TDA |
Accessor::VectorImageToImagePixelAccessor< TPixelType > > Superclass; |
| 120 |
TDA |
typedef SmartPointer<Self> Pointer; |
| 121 |
TDA |
typedef SmartPointer<const Self> ConstPointer; |
| 122 |
|
|
| 123 |
|
/** Method for creation through the object factory. */ |
| 124 |
|
itkNewMacro(Self); |
| 125 |
|
|
| 126 |
|
/** Run-time type information (and related methods). */ |
| 127 |
|
itkTypeMacro( VectorImageToImagePixelAccessor, ImageAdaptor ); |
| 128 |
|
|
| 129 |
|
/** PixelContainer typedef support. Used to construct a container for |
| 130 |
|
* the pixel data. */ |
| 131 |
|
typedef typename Superclass::PixelContainer PixelContainer; |
| 132 |
|
typedef typename Superclass::PixelContainerPointer PixelContainerPointer; |
| 133 |
LEN,TDA |
typedef typename Superclass::PixelContainerConstPointer PixelContainerConstPointer; |
| 134 |
TDA |
typedef typename Superclass::IOPixelType IOPixelType; |
| 135 |
|
|
| 136 |
|
/** Typedef for the length of vectors in the VectorImage. */ |
| 137 |
|
typedef typename VectorImageType::VectorLengthType VectorLengthType; |
| 138 |
|
|
| 139 |
|
// Set/GetMethods to set the component to be extracted. |
| 140 |
|
void SetExtractComponentIndex( VectorLengthType componentIdx ) |
| 141 |
|
{ |
| 142 |
|
this->GetPixelAccessor().SetExtractComponentIdx( componentIdx ); |
| 143 |
|
} |
| 144 |
|
|
| 145 |
|
// Set/GetMethods to set the component to be extracted. |
| 146 |
|
VectorLengthType GetExtractComponentIndex() const |
| 147 |
|
{ |
| 148 |
|
return this->GetPixelAccessor().GetExtractComponentIdx(); |
| 149 |
|
} |
| 150 |
|
|
| 151 |
IND |
*protected: |
| 152 |
|
VectorImageToImageAdaptor() {} |
| 153 |
|
virtual ~VectorImageToImageAdaptor() {} |
| 154 |
|
|
| 155 |
IND |
*private: |
| 156 |
|
VectorImageToImageAdaptor(const Self&); //purposely not implemented |
| 157 |
|
void operator=(const Self&); //purposely not implemented |
| 158 |
|
|
| 159 |
|
}; |
| 160 |
|
|
| 161 |
|
|
| 162 |
|
} // end namespace itk |
| 163 |
|
|
| 164 |
|
#endif |
| 165 |
|
|