ITK  5.3.0
Insight Toolkit
itkJointDomainImageToListSampleAdaptor.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  * 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 itkJointDomainImageToListSampleAdaptor_h
19 #define itkJointDomainImageToListSampleAdaptor_h
20 
21 #include "itkPoint.h"
22 #include "itkPixelTraits.h"
24 #include "itkImageRegionIterator.h"
25 #include "itkListSample.h"
26 
27 namespace itk
28 {
29 namespace Statistics
30 {
39 template <typename TImage>
41 {
45 
46  static constexpr unsigned int ImageDimension = TImage::ImageDimension;
47  static constexpr unsigned int Dimension = TImage::ImageDimension + PixelTraitsType::Dimension;
48 
49  using CoordinateRepType = float;
53 
55 }; // end of ImageJointDomainTraits
56 
87 template <typename TImage>
88 class ITK_TEMPLATE_EXPORT JointDomainImageToListSampleAdaptor
89  : public ListSample<typename ImageJointDomainTraits<TImage>::MeasurementVectorType>
90 {
91 public:
92  ITK_DISALLOW_COPY_AND_MOVE(JointDomainImageToListSampleAdaptor);
93 
96 
98 
101 
103 
109 
112 
114  itkNewMacro(Self);
115 
117  static constexpr unsigned int MeasurementVectorSize = ImageJointDomainTraitsType::Dimension;
118 
119  using MeasurementVectorSizeType = typename Superclass::MeasurementVectorSizeType;
120 
123  using AbsoluteFrequencyType = typename Superclass::AbsoluteFrequencyType;
124  using TotalAbsoluteFrequencyType = typename Superclass::TotalAbsoluteFrequencyType;
125  using InstanceIdentifier = typename Superclass::InstanceIdentifier;
126 
128  using ImageType = TImage;
131 
132  using ImagePointer = typename ImageType::Pointer;
133  using ImageConstPointer = typename ImageType::ConstPointer;
134  using PixelType = typename ImageType::PixelType;
135  using PixelContainerConstPointer = typename ImageType::PixelContainerConstPointer;
140 
142  void
143  SetImage(const TImage * image);
144 
146  const TImage *
147  GetImage() const;
148 
151  Size() const override;
152 
155  GetFrequency(InstanceIdentifier id) const override;
156 
159  GetTotalFrequency() const override;
160 
161  static constexpr unsigned int RangeDomainDimension = itk::PixelTraits<typename TImage::PixelType>::Dimension;
162 
164 
165  using InstanceIdentifierVectorType = std::vector<InstanceIdentifier>;
167 
169  void
170  SetNormalizationFactors(NormalizationFactorsType & factors);
171 
174  const MeasurementVectorType &
175  GetMeasurementVector(InstanceIdentifier id) const override;
176 
178  itkSetMacro(UsePixelContainer, bool);
179  itkGetConstMacro(UsePixelContainer, bool);
180  itkBooleanMacro(UsePixelContainer);
182 
183  // void PrintSelf(std::ostream& os, Indent indent) const override;
184 
190  {
192 
193  public:
194  ConstIterator() = delete;
195 
196  ConstIterator(const JointDomainImageToListSampleAdaptor * adaptor) { *this = adaptor->Begin(); }
197 
199  {
200  m_InstanceIdentifier = iter.m_InstanceIdentifier;
201  m_Adaptor = iter.m_Adaptor;
202  }
203 
204  ConstIterator &
205  operator=(const ConstIterator & iter)
206  {
207  m_InstanceIdentifier = iter.m_InstanceIdentifier;
208  return *this;
209  }
210 
212  GetFrequency() const
213  {
214  return 1;
215  }
216 
217  const MeasurementVectorType &
219  {
220  m_MeasurementVectorCache = m_Adaptor->GetMeasurementVector(m_InstanceIdentifier);
221  return this->m_MeasurementVectorCache;
222  }
223 
226  {
227  return m_InstanceIdentifier;
228  }
229 
230  ConstIterator &
232  {
233  ++m_InstanceIdentifier;
234  return *this;
235  }
236 
237  bool
238  operator==(const ConstIterator & it) const
239  {
240  return (m_InstanceIdentifier == it.m_InstanceIdentifier);
241  }
242 
243  ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(ConstIterator);
244 
245  protected:
246  // This method should only be available to the ListSample class
248  {
249  m_Adaptor = adaptor;
250  m_InstanceIdentifier = iid;
251  }
252 
253  private:
257  };
258 
263  class Iterator : public ConstIterator
264  {
266 
267  public:
268  Iterator() = delete;
269  Iterator(const Self * adaptor) = delete;
270  Iterator(const ConstIterator & it) = delete;
271  ConstIterator &
272  operator=(const ConstIterator & it) = delete;
273 
274  Iterator(Self * adaptor)
275  : ConstIterator(adaptor)
276  {}
277 
278  Iterator(const Iterator & iter)
279  : ConstIterator(iter)
280  {}
281 
282  Iterator &
283  operator=(const Iterator & iter)
284  {
285  this->ConstIterator::operator=(iter);
286  return *this;
287  }
288 
289  protected:
291  : ConstIterator(adaptor, iid)
292  {}
293  };
294 
296  Iterator
298  {
299  Iterator iter(this, 0);
300 
301  return iter;
302  }
303 
305  Iterator
306  End()
307  {
308  Iterator iter(this, m_Image->GetPixelContainer()->Size());
309 
310  return iter;
311  }
312 
314  ConstIterator
315  Begin() const
316  {
317  ConstIterator iter(this, 0);
318 
319  return iter;
320  }
321 
323  ConstIterator
324  End() const
325  {
326  ConstIterator iter(this, m_Image->GetPixelContainer()->Size());
327 
328  return iter;
329  }
330 
331 protected:
333  ~JointDomainImageToListSampleAdaptor() override = default;
334  void
335  PrintSelf(std::ostream & os, Indent indent) const override;
336 
337 private:
345 
347 }; // end of class JointDomainImageToListSampleAdaptor
348 } // end of namespace Statistics
349 } // end of namespace itk
350 
351 #ifndef ITK_MANUAL_INSTANTIATION
352 # include "itkJointDomainImageToListSampleAdaptor.hxx"
353 #endif
354 
355 #endif
itk::Statistics::JointDomainImageToListSampleAdaptor::MeasurementVectorType
typename ImageJointDomainTraitsType::MeasurementVectorType MeasurementVectorType
Definition: itkJointDomainImageToListSampleAdaptor.h:104
itk::Statistics::JointDomainImageToListSampleAdaptor::m_TempIndex
ImageIndexType m_TempIndex
Definition: itkJointDomainImageToListSampleAdaptor.h:341
itk::Statistics::JointDomainImageToListSampleAdaptor::m_NormalizationFactors
NormalizationFactorsType m_NormalizationFactors
Definition: itkJointDomainImageToListSampleAdaptor.h:338
itk::Statistics::JointDomainImageToListSampleAdaptor::ValueType
MeasurementVectorType ValueType
Definition: itkJointDomainImageToListSampleAdaptor.h:139
itk::Statistics::JointDomainImageToListSampleAdaptor::Begin
ConstIterator Begin() const
Definition: itkJointDomainImageToListSampleAdaptor.h:315
itkImageRegionConstIteratorWithIndex.h
itk::Statistics::JointDomainImageToListSampleAdaptor::CoordinateRepType
typename ImageJointDomainTraitsType::CoordinateRepType CoordinateRepType
Definition: itkJointDomainImageToListSampleAdaptor.h:108
itk::Size
Represent a n-dimensional size (bounds) of a n-dimensional image.
Definition: itkSize.h:69
itk::Statistics::JointDomainImageToListSampleAdaptor::AbsoluteFrequencyType
typename Superclass::AbsoluteFrequencyType AbsoluteFrequencyType
Definition: itkJointDomainImageToListSampleAdaptor.h:123
itk::Statistics::JointDomainImageToListSampleAdaptor::ConstIterator::operator==
bool operator==(const ConstIterator &it) const
Definition: itkJointDomainImageToListSampleAdaptor.h:238
itk::Statistics::JointDomainImageToListSampleAdaptor::Begin
Iterator Begin()
Definition: itkJointDomainImageToListSampleAdaptor.h:297
itkPoint.h
itk::Statistics::JointDomainImageToListSampleAdaptor::ConstIterator::ConstIterator
ConstIterator(const ConstIterator &iter)
Definition: itkJointDomainImageToListSampleAdaptor.h:198
itk::Statistics::JointDomainImageToListSampleAdaptor::ConstIterator::ConstIterator
ConstIterator(const JointDomainImageToListSampleAdaptor *adaptor)
Definition: itkJointDomainImageToListSampleAdaptor.h:196
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::Statistics::JointDomainImageToListSampleAdaptor
This adaptor returns measurement vectors composed of an image pixel's range domain value (pixel value...
Definition: itkJointDomainImageToListSampleAdaptor.h:88
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::Statistics::ListSample
This class is the native implementation of the a Sample with an STL container.
Definition: itkListSample.h:51
itk::Statistics::JointDomainImageToListSampleAdaptor::Iterator::Iterator
Iterator(const Iterator &iter)
Definition: itkJointDomainImageToListSampleAdaptor.h:278
itk::Statistics::JointDomainImageToListSampleAdaptor::m_UsePixelContainer
bool m_UsePixelContainer
Definition: itkJointDomainImageToListSampleAdaptor.h:344
itk::Statistics::JointDomainImageToListSampleAdaptor::ConstIterator::GetInstanceIdentifier
InstanceIdentifier GetInstanceIdentifier() const
Definition: itkJointDomainImageToListSampleAdaptor.h:225
itkPixelTraits.h
itk::SmartPointer< Self >
itkImageRegionIterator.h
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::Statistics::JointDomainImageToListSampleAdaptor::InstanceIdentifierVectorType
std::vector< InstanceIdentifier > InstanceIdentifierVectorType
Definition: itkJointDomainImageToListSampleAdaptor.h:165
itk::PixelTraits::Dimension
static constexpr unsigned int Dimension
Definition: itkPixelTraits.h:49
itk::PixelTraits
Traits for a pixel that define the dimension and component type.
Definition: itkPixelTraits.h:45
itk::Statistics::JointDomainImageToListSampleAdaptor::ImageRegionType
typename ImageType::RegionType ImageRegionType
Definition: itkJointDomainImageToListSampleAdaptor.h:138
itk::Statistics::JointDomainImageToListSampleAdaptor::InstanceIdentifier
typename Superclass::InstanceIdentifier InstanceIdentifier
Definition: itkJointDomainImageToListSampleAdaptor.h:125
itk::Statistics::JointDomainImageToListSampleAdaptor::ImageSizeType
typename ImageType::SizeType ImageSizeType
Definition: itkJointDomainImageToListSampleAdaptor.h:137
itk::Statistics::ImageJointDomainTraits::ImageDimension
static constexpr unsigned int ImageDimension
Definition: itkJointDomainImageToListSampleAdaptor.h:46
itk::Statistics::JointDomainImageToListSampleAdaptor::MeasurementVectorSizeType
typename Superclass::MeasurementVectorSizeType MeasurementVectorSizeType
Definition: itkJointDomainImageToListSampleAdaptor.h:119
itk::Statistics::JointDomainImageToListSampleAdaptor::ImageType
TImage ImageType
Definition: itkJointDomainImageToListSampleAdaptor.h:128
itk::Statistics::JointDomainImageToListSampleAdaptor::RangeDomainMeasurementType
typename ImageJointDomainTraitsType::RangeDomainMeasurementType RangeDomainMeasurementType
Definition: itkJointDomainImageToListSampleAdaptor.h:106
itk::JoinTraits
Trait to determine what datatype is needed if the specified pixel types are "joined" into a single ve...
Definition: itkPixelTraits.h:195
itk::ImageRegionIterator
A multi-dimensional iterator templated over image type that walks a region of pixels.
Definition: itkImageRegionIterator.h:80
itk::Statistics::JointDomainImageToListSampleAdaptor::m_TempPoint
PointType m_TempPoint
Definition: itkJointDomainImageToListSampleAdaptor.h:340
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::Statistics::JointDomainImageToListSampleAdaptor::ConstIterator::m_InstanceIdentifier
InstanceIdentifier m_InstanceIdentifier
Definition: itkJointDomainImageToListSampleAdaptor.h:255
itk::Statistics::JointDomainImageToListSampleAdaptor::ConstIterator::m_Adaptor
const JointDomainImageToListSampleAdaptor * m_Adaptor
Definition: itkJointDomainImageToListSampleAdaptor.h:256
itk::Statistics::JointDomainImageToListSampleAdaptor::ConstIterator::m_MeasurementVectorCache
MeasurementVectorType m_MeasurementVectorCache
Definition: itkJointDomainImageToListSampleAdaptor.h:254
itk::Statistics::JointDomainImageToListSampleAdaptor::Iterator::operator=
Iterator & operator=(const Iterator &iter)
Definition: itkJointDomainImageToListSampleAdaptor.h:283
itk::Statistics::JointDomainImageToListSampleAdaptor::Iterator::Iterator
Iterator(Self *adaptor)
Definition: itkJointDomainImageToListSampleAdaptor.h:274
itk::Statistics::JointDomainImageToListSampleAdaptor::PixelContainerConstPointer
typename ImageType::PixelContainerConstPointer PixelContainerConstPointer
Definition: itkJointDomainImageToListSampleAdaptor.h:135
itk::Statistics::JointDomainImageToListSampleAdaptor::TotalAbsoluteFrequencyType
typename Superclass::TotalAbsoluteFrequencyType TotalAbsoluteFrequencyType
Definition: itkJointDomainImageToListSampleAdaptor.h:124
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::Statistics::JointDomainImageToListSampleAdaptor::Iterator::Iterator
Iterator(const JointDomainImageToListSampleAdaptor *adaptor, InstanceIdentifier iid)
Definition: itkJointDomainImageToListSampleAdaptor.h:290
itk::Statistics::JointDomainImageToListSampleAdaptor::PixelType
typename ImageType::PixelType PixelType
Definition: itkJointDomainImageToListSampleAdaptor.h:134
itk::Statistics::JointDomainImageToListSampleAdaptor::ConstIterator
Const Iterator.
Definition: itkJointDomainImageToListSampleAdaptor.h:189
itk::Statistics::JointDomainImageToListSampleAdaptor::ConstIterator::GetFrequency
AbsoluteFrequencyType GetFrequency() const
Definition: itkJointDomainImageToListSampleAdaptor.h:212
itkListSample.h
itk::FixedArray
Simulate a standard C array with copy semantics.
Definition: itkFixedArray.h:52
itk::Statistics::JointDomainImageToListSampleAdaptor::End
Iterator End()
Definition: itkJointDomainImageToListSampleAdaptor.h:306
itk::JoinTraits::ValueType
TValue1 ValueType
Definition: itkPixelTraits.h:198
itk::Statistics::JointDomainImageToListSampleAdaptor::ConstIterator::operator=
ConstIterator & operator=(const ConstIterator &iter)
Definition: itkJointDomainImageToListSampleAdaptor.h:205
itk::Statistics::ImageJointDomainTraits
This class provides the type definition for the measurement vector in the joint domain (range domain ...
Definition: itkJointDomainImageToListSampleAdaptor.h:40
itk::Statistics::JointDomainImageToListSampleAdaptor::m_PixelContainer
PixelContainerConstPointer m_PixelContainer
Definition: itkJointDomainImageToListSampleAdaptor.h:346
itk::Statistics::ImageJointDomainTraits::Dimension
static constexpr unsigned int Dimension
Definition: itkJointDomainImageToListSampleAdaptor.h:47
itk::Statistics::ImageJointDomainTraits::CoordinateRepType
float CoordinateRepType
Definition: itkJointDomainImageToListSampleAdaptor.h:49
itk::PixelTraits::ValueType
typename TPixelType::ValueType ValueType
Definition: itkPixelTraits.h:52
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::Statistics::JointDomainImageToListSampleAdaptor::ConstIterator::operator++
ConstIterator & operator++()
Definition: itkJointDomainImageToListSampleAdaptor.h:231
itk::Statistics::JointDomainImageToListSampleAdaptor::m_TempRangeVector
RangeDomainMeasurementVectorType m_TempRangeVector
Definition: itkJointDomainImageToListSampleAdaptor.h:342
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:62
itk::ImageRegionConstIterator< ImageType >
itk::Point
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:53
itk::Statistics::JointDomainImageToListSampleAdaptor::MeasurementType
typename ImageJointDomainTraitsType::MeasurementType MeasurementType
Definition: itkJointDomainImageToListSampleAdaptor.h:105
itk::Statistics::JointDomainImageToListSampleAdaptor::m_TempVector
MeasurementVectorType m_TempVector
Definition: itkJointDomainImageToListSampleAdaptor.h:339
itk::Statistics::ImageJointDomainTraits::RangeDomainMeasurementType
typename PixelTraitsType::ValueType RangeDomainMeasurementType
Definition: itkJointDomainImageToListSampleAdaptor.h:44
itk::Statistics::JointDomainImageToListSampleAdaptor::ImagePointer
typename ImageType::Pointer ImagePointer
Definition: itkJointDomainImageToListSampleAdaptor.h:132
itk::Statistics::JointDomainImageToListSampleAdaptor::ConstIterator::GetMeasurementVector
const MeasurementVectorType & GetMeasurementVector() const
Definition: itkJointDomainImageToListSampleAdaptor.h:218
itk::Statistics::JointDomainImageToListSampleAdaptor::ConstIterator::ConstIterator
ConstIterator(const JointDomainImageToListSampleAdaptor *adaptor, InstanceIdentifier iid)
Definition: itkJointDomainImageToListSampleAdaptor.h:247
itk::Statistics::JointDomainImageToListSampleAdaptor::PointType
typename ImageJointDomainTraitsType::PointType PointType
Definition: itkJointDomainImageToListSampleAdaptor.h:107
itk::Statistics::JointDomainImageToListSampleAdaptor::ImageConstPointer
typename ImageType::ConstPointer ImageConstPointer
Definition: itkJointDomainImageToListSampleAdaptor.h:133
itk::GTest::TypedefsAndConstructors::Dimension2::Dimension
constexpr unsigned int Dimension
Definition: itkGTestTypedefsAndConstructors.h:44
itk::Statistics::ImageJointDomainTraits::MeasurementType
typename JoinTraitsType::ValueType MeasurementType
Definition: itkJointDomainImageToListSampleAdaptor.h:52
itk::Statistics::JointDomainImageToListSampleAdaptor::Iterator
Iterator.
Definition: itkJointDomainImageToListSampleAdaptor.h:263
itk::Statistics::JointDomainImageToListSampleAdaptor::End
ConstIterator End() const
Definition: itkJointDomainImageToListSampleAdaptor.h:324
itk::Statistics::JointDomainImageToListSampleAdaptor::ImageIndexType
typename ImageType::IndexType ImageIndexType
Definition: itkJointDomainImageToListSampleAdaptor.h:136
itk::Statistics::JointDomainImageToListSampleAdaptor::m_Image
ImageConstPointer m_Image
Definition: itkJointDomainImageToListSampleAdaptor.h:343
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293