ITK  6.0.0
Insight Toolkit
itkVectorImageToImageAdaptor.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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 itkVectorImageToImageAdaptor_h
19 #define itkVectorImageToImageAdaptor_h
20 
21 #include "itkImageAdaptor.h"
22 #include "itkVectorImage.h"
23 
24 namespace itk
25 {
26 namespace Accessor
27 {
47 template <typename TType>
49 {
50 public:
51  using VectorLengthType = unsigned int;
52 
55  using ExternalType = TType;
56 
58  using InternalType = TType;
59 
61 
62  inline void
63  Set(ActualPixelType output, const ExternalType & input) const
64  {
65  output[m_ComponentIdx] = input;
66  }
67 
68  inline void
69  Set(InternalType & output, const ExternalType & input, const unsigned long offset) const
70  {
71  return Set(Superclass::Get(output, offset), input);
72  }
73 
74  inline ExternalType
75  Get(const ActualPixelType & input) const
76  {
77  ExternalType output = input[m_ComponentIdx];
78  return output;
79  }
80 
81  inline ExternalType
82  Get(const InternalType & input, const SizeValueType offset) const
83  {
84  return Get(Superclass::Get(input, offset));
85  }
86 
87  void
89  {
90  m_ComponentIdx = idx;
91  }
92 
95  {
96  return m_ComponentIdx;
97  }
98 
100  void
102  {
104  }
105 
109  {
111  }
112 
113  VectorImageToImagePixelAccessor(unsigned int length = 1) { Superclass::SetVectorLength(length); }
114 
115 protected:
117 
118 private:
120 };
121 } // end namespace Accessor
122 
145 template <typename TPixelType, unsigned int Dimension>
147  : public ImageAdaptor<VectorImage<TPixelType, Dimension>, Accessor::VectorImageToImagePixelAccessor<TPixelType>>
148 {
149 public:
150  ITK_DISALLOW_COPY_AND_MOVE(VectorImageToImageAdaptor);
151 
156 
159 
161  itkNewMacro(Self);
162 
164  itkOverrideGetNameOfClassMacro(VectorImageToImageAdaptor);
165 
168  using typename Superclass::PixelContainer;
169  using typename Superclass::PixelContainerPointer;
171  using typename Superclass::IOPixelType;
172 
175 
176  // Set/GetMethods to set the component to be extracted.
177  void
179  {
180  this->GetPixelAccessor().SetExtractComponentIdx(componentIdx);
181  }
182 
183  // Set/GetMethods to set the component to be extracted.
186  {
187  return this->GetPixelAccessor().GetExtractComponentIdx();
188  }
189 
190 protected:
191  VectorImageToImageAdaptor() = default;
192  ~VectorImageToImageAdaptor() override = default;
193 };
194 } // end namespace itk
195 
196 #endif
itk::Accessor::VectorImageToImagePixelAccessor::Set
void Set(ActualPixelType output, const ExternalType &input) const
Definition: itkVectorImageToImageAdaptor.h:63
itk::ImageAdaptor::PixelContainerConstPointer
typename TImage::PixelContainerConstPointer PixelContainerConstPointer
Definition: itkImageAdaptor.h:241
itk::Accessor::VectorImageToImagePixelAccessor::m_ComponentIdx
VectorLengthType m_ComponentIdx
Definition: itkVectorImageToImageAdaptor.h:119
itk::VectorImageToImageAdaptor::~VectorImageToImageAdaptor
~VectorImageToImageAdaptor() override=default
itk::Accessor::VectorImageToImagePixelAccessor::GetVectorLength
VectorLengthType GetVectorLength() const
Definition: itkVectorImageToImageAdaptor.h:108
itk::VectorImageToImageAdaptor
Presents a VectorImage and extracts a component from it into an image.
Definition: itkVectorImageToImageAdaptor.h:146
itk::ImageAdaptor::PixelContainer
typename TImage::PixelContainer PixelContainer
Definition: itkImageAdaptor.h:239
itk::Accessor::VectorImageToImagePixelAccessor
Extract components from a VectorImage.
Definition: itkVectorImageToImageAdaptor.h:48
itk::VectorImage< TPixelType, Dimension >
itk::VectorImageToImageAdaptor::SetExtractComponentIndex
void SetExtractComponentIndex(VectorLengthType componentIdx)
Definition: itkVectorImageToImageAdaptor.h:178
itk::Accessor::VectorImageToImagePixelAccessor::VectorImageToImagePixelAccessor
VectorImageToImagePixelAccessor(unsigned int length=1)
Definition: itkVectorImageToImageAdaptor.h:113
itk::DefaultVectorPixelAccessor< TPixelType >::InternalType
TPixelType InternalType
Definition: itkDefaultVectorPixelAccessor.h:62
itk::VectorImageToImageAdaptor::VectorImageToImageAdaptor
VectorImageToImageAdaptor()=default
itk::SmartPointer< Self >
itkImageAdaptor.h
itk::ImageAdaptor
Give access to partial aspects of voxels from an Image.
Definition: itkImageAdaptor.h:56
itkVectorImage.h
itk::DefaultVectorPixelAccessor::Get
ExternalType Get(const InternalType &input, const SizeValueType offset) const
Definition: itkDefaultVectorPixelAccessor.h:78
itk::Accessor::VectorImageToImagePixelAccessor::VectorLengthType
unsigned int VectorLengthType
Definition: itkVectorImageToImageAdaptor.h:51
itk::Accessor::VectorImageToImagePixelAccessor::Get
ExternalType Get(const InternalType &input, const SizeValueType offset) const
Definition: itkVectorImageToImageAdaptor.h:82
itk::Accessor::VectorImageToImagePixelAccessor::ExternalType
TType ExternalType
Definition: itkVectorImageToImageAdaptor.h:55
itk::Accessor::VectorImageToImagePixelAccessor::Set
void Set(InternalType &output, const ExternalType &input, const unsigned long offset) const
Definition: itkVectorImageToImageAdaptor.h:69
itk::DefaultVectorPixelAccessor
Give access to partial aspects of a type.
Definition: itkDefaultVectorPixelAccessor.h:50
itk::VectorImageToImageAdaptor::VectorLengthType
typename VectorImageType::VectorLengthType VectorLengthType
Definition: itkVectorImageToImageAdaptor.h:174
itk::Accessor::VectorImageToImagePixelAccessor::Get
ExternalType Get(const ActualPixelType &input) const
Definition: itkVectorImageToImageAdaptor.h:75
itk::VariableLengthVector
Represents an array whose length can be defined at run-time.
Definition: itkConstantBoundaryCondition.h:28
itk::Accessor::VectorImageToImagePixelAccessor::SetVectorLength
void SetVectorLength(VectorLengthType l)
Definition: itkVectorImageToImageAdaptor.h:101
itk::DefaultVectorPixelAccessor::SetVectorLength
void SetVectorLength(VectorLengthType l)
Definition: itkDefaultVectorPixelAccessor.h:87
itk::ImageAdaptor::PixelContainerPointer
typename TImage::PixelContainerPointer PixelContainerPointer
Definition: itkImageAdaptor.h:240
itk::VectorImageToImageAdaptor::GetExtractComponentIndex
VectorLengthType GetExtractComponentIndex() const
Definition: itkVectorImageToImageAdaptor.h:185
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::DefaultVectorPixelAccessor< TPixelType >::VectorLengthType
unsigned int VectorLengthType
Definition: itkDefaultVectorPixelAccessor.h:53
itk::Accessor::VectorImageToImagePixelAccessor::SetExtractComponentIdx
void SetExtractComponentIdx(VectorLengthType idx)
Definition: itkVectorImageToImageAdaptor.h:88
itk::DefaultVectorPixelAccessor::GetVectorLength
VectorLengthType GetVectorLength() const
Definition: itkDefaultVectorPixelAccessor.h:96
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itk::Accessor::VectorImageToImagePixelAccessor::GetExtractComponentIdx
VectorLengthType GetExtractComponentIdx() const
Definition: itkVectorImageToImageAdaptor.h:94
itk::ImageAdaptor< VectorImage< TPixelType, Dimension >, Accessor::VectorImageToImagePixelAccessor< TPixelType > >::GetPixelAccessor
AccessorType & GetPixelAccessor()
Definition: itkImageAdaptor.h:343
itk::VectorImage< TPixelType, Dimension >::VectorLengthType
unsigned int VectorLengthType
Definition: itkVectorImage.h:168
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86
itk::ImageAdaptor::IOPixelType
PixelType IOPixelType
Definition: itkImageAdaptor.h:91
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293