ITK  5.2.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  bool
244  operator==(const ConstIterator & it) const
245  {
246  return (m_InstanceIdentifier == it.m_InstanceIdentifier);
247  }
248 
249  protected:
250  // This method should only be available to the ListSample class
252  {
253  m_Adaptor = adaptor;
254  m_InstanceIdentifier = iid;
255  }
256 
257  private:
261  };
262 
267  class Iterator : public ConstIterator
268  {
270 
271  public:
272  Iterator() = delete;
273  Iterator(const Self * adaptor) = delete;
274  Iterator(const ConstIterator & it) = delete;
275  ConstIterator &
276  operator=(const ConstIterator & it) = delete;
277 
278  Iterator(Self * adaptor)
279  : ConstIterator(adaptor)
280  {}
281 
282  Iterator(const Iterator & iter)
283  : ConstIterator(iter)
284  {}
285 
286  Iterator &
287  operator=(const Iterator & iter)
288  {
289  this->ConstIterator::operator=(iter);
290  return *this;
291  }
292 
293  protected:
295  : ConstIterator(adaptor, iid)
296  {}
297  };
298 
300  Iterator
302  {
303  Iterator iter(this, 0);
304 
305  return iter;
306  }
307 
309  Iterator
310  End()
311  {
312  Iterator iter(this, m_Image->GetPixelContainer()->Size());
313 
314  return iter;
315  }
316 
318  ConstIterator
319  Begin() const
320  {
321  ConstIterator iter(this, 0);
322 
323  return iter;
324  }
325 
327  ConstIterator
328  End() const
329  {
330  ConstIterator iter(this, m_Image->GetPixelContainer()->Size());
331 
332  return iter;
333  }
334 
335 protected:
337  ~JointDomainImageToListSampleAdaptor() override = default;
338  void
339  PrintSelf(std::ostream & os, Indent indent) const override;
340 
341 private:
349 
351 }; // end of class JointDomainImageToListSampleAdaptor
352 } // end of namespace Statistics
353 } // end of namespace itk
354 
355 #ifndef ITK_MANUAL_INSTANTIATION
356 # include "itkJointDomainImageToListSampleAdaptor.hxx"
357 #endif
358 
359 #endif
itk::Statistics::JointDomainImageToListSampleAdaptor::MeasurementVectorType
typename ImageJointDomainTraitsType::MeasurementVectorType MeasurementVectorType
Definition: itkJointDomainImageToListSampleAdaptor.h:104
itk::Statistics::JointDomainImageToListSampleAdaptor::m_TempIndex
ImageIndexType m_TempIndex
Definition: itkJointDomainImageToListSampleAdaptor.h:345
itk::Statistics::JointDomainImageToListSampleAdaptor::m_NormalizationFactors
NormalizationFactorsType m_NormalizationFactors
Definition: itkJointDomainImageToListSampleAdaptor.h:342
itk::Statistics::JointDomainImageToListSampleAdaptor::ValueType
MeasurementVectorType ValueType
Definition: itkJointDomainImageToListSampleAdaptor.h:139
itk::Statistics::JointDomainImageToListSampleAdaptor::Begin
ConstIterator Begin() const
Definition: itkJointDomainImageToListSampleAdaptor.h:319
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:244
itk::Statistics::JointDomainImageToListSampleAdaptor::Begin
Iterator Begin()
Definition: itkJointDomainImageToListSampleAdaptor.h:301
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:282
itk::Statistics::JointDomainImageToListSampleAdaptor::m_UsePixelContainer
bool m_UsePixelContainer
Definition: itkJointDomainImageToListSampleAdaptor.h:348
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:344
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::Statistics::JointDomainImageToListSampleAdaptor::ConstIterator::m_InstanceIdentifier
InstanceIdentifier m_InstanceIdentifier
Definition: itkJointDomainImageToListSampleAdaptor.h:259
itk::Statistics::JointDomainImageToListSampleAdaptor::ConstIterator::m_Adaptor
const JointDomainImageToListSampleAdaptor * m_Adaptor
Definition: itkJointDomainImageToListSampleAdaptor.h:260
itk::Statistics::JointDomainImageToListSampleAdaptor::ConstIterator::m_MeasurementVectorCache
MeasurementVectorType m_MeasurementVectorCache
Definition: itkJointDomainImageToListSampleAdaptor.h:258
itk::Statistics::JointDomainImageToListSampleAdaptor::Iterator::operator=
Iterator & operator=(const Iterator &iter)
Definition: itkJointDomainImageToListSampleAdaptor.h:287
itk::Statistics::JointDomainImageToListSampleAdaptor::Iterator::Iterator
Iterator(Self *adaptor)
Definition: itkJointDomainImageToListSampleAdaptor.h:278
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:294
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:310
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:350
itk::Statistics::JointDomainImageToListSampleAdaptor::ConstIterator::operator!=
bool operator!=(const ConstIterator &it) const
Definition: itkJointDomainImageToListSampleAdaptor.h:238
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:346
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:343
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:251
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:267
itk::Statistics::JointDomainImageToListSampleAdaptor::End
ConstIterator End() const
Definition: itkJointDomainImageToListSampleAdaptor.h:328
itk::Statistics::JointDomainImageToListSampleAdaptor::ImageIndexType
typename ImageType::IndexType ImageIndexType
Definition: itkJointDomainImageToListSampleAdaptor.h:136
itk::Statistics::JointDomainImageToListSampleAdaptor::m_Image
ImageConstPointer m_Image
Definition: itkJointDomainImageToListSampleAdaptor.h:347
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293