ITK  5.4.0
Insight Toolkit
itkSpatialObjectToImageStatisticsCalculator.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 itkSpatialObjectToImageStatisticsCalculator_h
19 #define itkSpatialObjectToImageStatisticsCalculator_h
20 
21 #include "itkObject.h"
22 #include "itkMatrix.h"
23 #include "itkNumericTraits.h"
24 #include "itkListSample.h"
25 #include "itkVector.h"
26 
27 namespace itk
28 {
36 template <typename TInputImage, typename TInputSpatialObject, unsigned int TSampleDimension = 1>
37 class ITK_TEMPLATE_EXPORT SpatialObjectToImageStatisticsCalculator : public Object
38 {
39 public:
40  ITK_DISALLOW_COPY_AND_MOVE(SpatialObjectToImageStatisticsCalculator);
41 
44  using Superclass = Object;
47 
49  itkNewMacro(Self);
50 
52  itkOverrideGetNameOfClassMacro(SpatialObjectToImageStatisticsCalculator);
53 
55  using ImageType = TInputImage;
58  using PixelType = typename TInputImage::PixelType;
62  using SizeType = typename RegionType::SizeType;
63 
65 
66  static constexpr unsigned int ImageDimension = ImageType::ImageDimension;
67 
68  static constexpr unsigned int SampleDimension = TSampleDimension;
69 
70  static constexpr unsigned int ObjectDimension = TInputSpatialObject::ObjectDimension;
71 
73  using SpatialObjectType = TInputSpatialObject;
76 
80 
83 
85  itkSetMacro(SampleDirection, unsigned int);
86  itkGetConstMacro(SampleDirection, unsigned int);
90  itkSetConstObjectMacro(Image, ImageType);
91 
93  itkSetObjectMacro(SpatialObject, SpatialObjectType);
94 
96  const VectorType &
97  GetMean() const
98  {
99  return m_Mean;
100  }
101 
103  const MatrixType &
105  {
106  return m_CovarianceMatrix;
107  }
108 
110  AccumulateType
111  GetSum() const
112  {
113  return m_Sum;
114  }
115 
117  itkGetConstMacro(NumberOfPixels, SizeValueType);
118 
120  void
121  Update();
122 
123 protected:
125  ~SpatialObjectToImageStatisticsCalculator() override = default;
126  void
127  PrintSelf(std::ostream & os, Indent indent) const override;
128 
130  bool
131  ComputeStatistics();
132 
133 private:
134  ImageConstPointer m_Image{};
135  SpatialObjectPointer m_SpatialObject{};
136  VectorType m_Mean{};
137  AccumulateType m_Sum{};
138  SizeValueType m_NumberOfPixels{};
139  MatrixType m_CovarianceMatrix{};
140  unsigned int m_SampleDirection{};
141  ModifiedTimeType m_InternalImageTime{};
142  ModifiedTimeType m_InternalSpatialObjectTime{};
143  TimeStamp m_ModifiedTime{};
144 
145  typename SampleType::Pointer m_Sample{};
146 };
147 } // end namespace itk
148 
149 #ifndef ITK_MANUAL_INSTANTIATION
150 # include "itkSpatialObjectToImageStatisticsCalculator.hxx"
151 #endif
152 
153 #endif /* itkSpatialObjectToImageStatisticsCalculator_h */
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::SpatialObjectToImageStatisticsCalculator::SpatialObjectType
TInputSpatialObject SpatialObjectType
Definition: itkSpatialObjectToImageStatisticsCalculator.h:73
itk::SpatialObjectToImageStatisticsCalculator::GetSum
AccumulateType GetSum() const
Definition: itkSpatialObjectToImageStatisticsCalculator.h:111
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::SpatialObjectToImageStatisticsCalculator::GetCovarianceMatrix
const MatrixType & GetCovarianceMatrix() const
Definition: itkSpatialObjectToImageStatisticsCalculator.h:104
itk::ModifiedTimeType
SizeValueType ModifiedTimeType
Definition: itkIntTypes.h:102
itkMatrix.h
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::Vector< double, TSampleDimension >
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::SpatialObjectToImageStatisticsCalculator::SizeType
typename RegionType::SizeType SizeType
Definition: itkSpatialObjectToImageStatisticsCalculator.h:62
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::SpatialObjectToImageStatisticsCalculator::ImageConstPointer
typename TInputImage::ConstPointer ImageConstPointer
Definition: itkSpatialObjectToImageStatisticsCalculator.h:57
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::SpatialObjectToImageStatisticsCalculator::PointType
typename TInputImage::PointType PointType
Definition: itkSpatialObjectToImageStatisticsCalculator.h:60
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::SpatialObjectToImageStatisticsCalculator::SpatialObjectPointer
typename SpatialObjectType::Pointer SpatialObjectPointer
Definition: itkSpatialObjectToImageStatisticsCalculator.h:74
itk::SpatialObjectToImageStatisticsCalculator
Definition: itkSpatialObjectToImageStatisticsCalculator.h:37
itk::SpatialObjectToImageStatisticsCalculator::AccumulateType
typename NumericTraits< PixelType >::AccumulateType AccumulateType
Definition: itkSpatialObjectToImageStatisticsCalculator.h:64
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::SpatialObjectToImageStatisticsCalculator::GetMean
const VectorType & GetMean() const
Definition: itkSpatialObjectToImageStatisticsCalculator.h:97
itk::SpatialObject
Implementation of the composite pattern.
Definition: itkSpatialObject.h:58
itk::TimeStamp
Generate a unique, increasing time value.
Definition: itkTimeStamp.h:60
itkListSample.h
itk::Matrix< double, TSampleDimension, TSampleDimension >
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:59
itk::SpatialObjectToImageStatisticsCalculator::SpatialObjectConstPointer
typename SpatialObjectType::ConstPointer SpatialObjectConstPointer
Definition: itkSpatialObjectToImageStatisticsCalculator.h:75
itk::SpatialObjectToImageStatisticsCalculator::ImagePointer
typename TInputImage::Pointer ImagePointer
Definition: itkSpatialObjectToImageStatisticsCalculator.h:56
itkObject.h
itk::SpatialObjectToImageStatisticsCalculator::IndexType
typename TInputImage::IndexType IndexType
Definition: itkSpatialObjectToImageStatisticsCalculator.h:59
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itkVector.h
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itk::SpatialObjectToImageStatisticsCalculator::RegionType
typename TInputImage::RegionType RegionType
Definition: itkSpatialObjectToImageStatisticsCalculator.h:61
itkNumericTraits.h
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:88
itk::SpatialObjectToImageStatisticsCalculator::PixelType
typename TInputImage::PixelType PixelType
Definition: itkSpatialObjectToImageStatisticsCalculator.h:58
itk::SpatialObjectToImageStatisticsCalculator::ImageType
TInputImage ImageType
Definition: itkSpatialObjectToImageStatisticsCalculator.h:55
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83