ITK  6.0.0
Insight Toolkit
itkObjectToObjectMetric.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 itkObjectToObjectMetric_h
19 #define itkObjectToObjectMetric_h
20 
21 
23 
25 #include "itkImage.h"
26 #include "itkObject.h"
27 #include "itkPointSet.h"
28 #include "itkTransform.h"
29 
30 namespace itk
31 {
32 
88 template <unsigned int TFixedDimension,
89  unsigned int TMovingDimension,
90  typename TVirtualImage = Image<double, TFixedDimension>,
91  typename TParametersValueType = double>
92 class ITK_TEMPLATE_EXPORT ObjectToObjectMetric : public ObjectToObjectMetricBaseTemplate<TParametersValueType>
93 {
94 public:
95  ITK_DISALLOW_COPY_AND_MOVE(ObjectToObjectMetric);
96 
102 
104  itkOverrideGetNameOfClassMacro(ObjectToObjectMetric);
105 
107  using CoordinateRepresentationType = TParametersValueType;
108 
110  using InternalComputationValueType = TParametersValueType;
111 
113  using typename Superclass::MeasureType;
114 
116  using ObjectType = typename Superclass::Object;
117 
119  using typename Superclass::DerivativeType;
120  using typename Superclass::DerivativeValueType;
121 
123  using typename Superclass::ParametersType;
124  using typename Superclass::NumberOfParametersType;
125 
126  using typename Superclass::GradientSourceEnum;
127 
130 
132  static constexpr DimensionType FixedDimension = TFixedDimension;
133  static constexpr DimensionType MovingDimension = TMovingDimension;
134  static constexpr DimensionType VirtualDimension = TVirtualImage::ImageDimension;
135 
137  using VirtualImageType = TVirtualImage;
149 
153 
157 
161  using FixedTransformParametersType = typename FixedTransformType::ParametersType;
162 
166  using MovingTransformParametersType = typename MovingTransformType::ParametersType;
167 
172 
176 
177  void
178  Initialize() override;
179 
181  GetNumberOfParameters() const override;
183  GetNumberOfLocalParameters() const override;
184  void
185  SetParameters(ParametersType & params) override;
186  const ParametersType &
187  GetParameters() const override;
188  bool
189  HasLocalSupport() const override;
190  void
191  UpdateTransformParameters(const DerivativeType & derivative, TParametersValueType factor) override;
192 
194  itkSetObjectMacro(FixedTransform, FixedTransformType);
195 
197  itkGetModifiableObjectMacro(FixedTransform, FixedTransformType);
198 
200  itkSetObjectMacro(MovingTransform, MovingTransformType);
201 
203  itkGetModifiableObjectMacro(MovingTransform, MovingTransformType);
204 
207  void
208  SetTransform(MovingTransformType * transform);
209 
211  const MovingTransformType *
212  GetTransform();
213 
216  itkGetConstMacro(NumberOfValidPoints, SizeValueType);
217 
234  void
235  SetVirtualDomain(const VirtualSpacingType & spacing,
236  const VirtualOriginType & origin,
237  const VirtualDirectionType & direction,
238  const VirtualRegionType & region);
239 
242  void
243  SetVirtualDomainFromImage(const VirtualImageType * virtualImage);
244 
249  virtual bool
250  SupportsArbitraryVirtualDomainSamples() const = 0;
251 
257  virtual const TimeStamp &
258  GetVirtualDomainTimeStamp() const;
259 
263  GetVirtualSpacing() const;
264 
268  GetVirtualOrigin() const;
269 
273  GetVirtualDirection() const;
274 
277  const VirtualRegionType &
278  GetVirtualRegion() const;
279 
280  itkGetModifiableObjectMacro(VirtualImage, VirtualImageType);
281 
292  ComputeParameterOffsetFromVirtualIndex(const VirtualIndexType & index,
293  const NumberOfParametersType & numberOfLocalParameters) const;
294 
305  ComputeParameterOffsetFromVirtualPoint(const VirtualPointType & point,
306  const NumberOfParametersType & numberOfLocalParameters) const;
307 
312  bool
313  IsInsideVirtualDomain(const VirtualPointType & point) const;
314  bool
315  IsInsideVirtualDomain(const VirtualIndexType & index) const;
318  using MetricCategoryType = typename Superclass::MetricCategoryEnum;
319 
322  GetMetricCategory() const override
323  {
324  return MetricCategoryType::OBJECT_METRIC;
325  }
326 
327 protected:
329  ~ObjectToObjectMetric() override = default;
330 
331  void
332  PrintSelf(std::ostream & os, Indent indent) const override;
333 
336  virtual void
337  VerifyDisplacementFieldSizeAndPhysicalSpace();
338 
339  bool
340  TransformPhysicalPointToVirtualIndex(const VirtualPointType &, VirtualIndexType &) const;
341  void
342  TransformVirtualIndexToPhysicalPoint(const VirtualIndexType &, VirtualPointType &) const;
343 
348  const MovingDisplacementFieldTransformType *
349  GetMovingDisplacementFieldTransform() const;
350 
357  bool
358  VerifyNumberOfValidPoints(MeasureType & value, DerivativeType & derivative) const;
359 
361  FixedTransformPointer m_FixedTransform{};
362  MovingTransformPointer m_MovingTransform{};
363 
364  VirtualImagePointer m_VirtualImage{};
365 
368  bool m_UserHasSetVirtualDomain{};
369 
373  mutable SizeValueType m_NumberOfValidPoints{ 0 };
374 };
375 } // end namespace itk
376 
377 #ifndef ITK_MANUAL_INSTANTIATION
378 # include "itkObjectToObjectMetric.hxx"
379 #endif
380 
381 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::MovingTransformPointer
typename MovingTransformType::Pointer MovingTransformPointer
Definition: itkObjectToObjectMetric.h:163
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::DimensionType
SizeValueType DimensionType
Definition: itkObjectToObjectMetric.h:129
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::VirtualRadiusType
typename VirtualImageType::SizeType VirtualRadiusType
Definition: itkObjectToObjectMetric.h:147
itk::OptimizerParameters< TInternalComputationValueType >
itkDisplacementFieldTransform.h
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::GTest::TypedefsAndConstructors::Dimension2::DirectionType
ImageBaseType::DirectionType DirectionType
Definition: itkGTestTypedefsAndConstructors.h:52
itk::PointSet
A superclass of the N-dimensional mesh structure; supports point (geometric coordinate and attribute)...
Definition: itkPointSet.h:81
itk::ObjectToObjectMetricBaseTemplate::NumberOfParametersType
unsigned int NumberOfParametersType
Definition: itkObjectToObjectMetricBase.h:176
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::Vector< SpacingValueType, VImageDimension >
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::FixedOutputPointType
typename FixedTransformType::OutputPointType FixedOutputPointType
Definition: itkObjectToObjectMetric.h:160
itkImage.h
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::FixedInputPointType
typename FixedTransformType::InputPointType FixedInputPointType
Definition: itkObjectToObjectMetric.h:159
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::MovingOutputPointType
typename MovingTransformType::OutputPointType MovingOutputPointType
Definition: itkObjectToObjectMetric.h:165
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::VirtualDirectionType
typename VirtualImageType::DirectionType VirtualDirectionType
Definition: itkObjectToObjectMetric.h:146
itk::DisplacementFieldTransform
Provides local/dense/high-dimensionality transformation via a a displacement field.
Definition: itkDisplacementFieldTransform.h:87
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::VirtualRegionType
typename VirtualImageType::RegionType VirtualRegionType
Definition: itkObjectToObjectMetric.h:141
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::FixedTransformPointer
typename FixedTransformType::Pointer FixedTransformPointer
Definition: itkObjectToObjectMetric.h:158
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::MovingInputPointType
typename MovingTransformType::InputPointType MovingInputPointType
Definition: itkObjectToObjectMetric.h:164
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::VirtualPointSetPointer
typename VirtualPointSetType::Pointer VirtualPointSetPointer
Definition: itkObjectToObjectMetric.h:152
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::MetricCategoryType
typename Superclass::MetricCategoryEnum MetricCategoryType
Definition: itkObjectToObjectMetric.h:318
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::JacobianType
typename FixedTransformType::JacobianType JacobianType
Definition: itkObjectToObjectMetric.h:169
itk::point
*par Constraints *The filter requires an image with at least two dimensions and a vector *length of at least The theory supports extension to scalar but *the implementation of the itk vector classes do not **The template parameter TRealType must be floating point(float or double) or *a user-defined "real" numerical type with arithmetic operations defined *sufficient to compute derivatives. **\par Performance *This filter will automatically multithread if run with *SetUsePrincipleComponents
itk::ObjectToObjectMetricBaseTemplate::CoordinateRepresentationType
TInternalComputationValueType CoordinateRepresentationType
Definition: itkObjectToObjectMetricBase.h:106
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::VirtualIndexType
typename VirtualImageType::IndexType VirtualIndexType
Definition: itkObjectToObjectMetric.h:148
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::FixedTransformParametersType
typename FixedTransformType::ParametersType FixedTransformParametersType
Definition: itkObjectToObjectMetric.h:161
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::MovingTransformParametersType
typename MovingTransformType::ParametersType MovingTransformParametersType
Definition: itkObjectToObjectMetric.h:166
itk::ObjectToObjectMetricBaseTemplate
Base class for all object-to-object similarity metrics added in ITKv4.
Definition: itkObjectToObjectMetricBase.h:90
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::VirtualOriginType
typename VirtualImageType::PointType VirtualOriginType
Definition: itkObjectToObjectMetric.h:144
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::VirtualPointType
typename VirtualImageType::PointType VirtualPointType
Definition: itkObjectToObjectMetric.h:145
itk::TimeStamp
Generate a unique, increasing time value.
Definition: itkTimeStamp.h:60
itk::OffsetValueType
long OffsetValueType
Definition: itkIntTypes.h:97
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::MovingTransformJacobianType
typename MovingTransformType::JacobianType MovingTransformJacobianType
Definition: itkObjectToObjectMetric.h:171
itk::Image::PixelType
TPixel PixelType
Definition: itkImage.h:108
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::InternalComputationValueType
TInternalComputationValueType InternalComputationValueType
Definition: itkObjectToObjectMetric.h:110
itkObjectToObjectMetricBase.h
itkObject.h
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::VirtualImageConstPointer
typename VirtualImageType::ConstPointer VirtualImageConstPointer
Definition: itkObjectToObjectMetric.h:139
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::VirtualSpacingType
typename VirtualImageType::SpacingType VirtualSpacingType
Definition: itkObjectToObjectMetric.h:143
itk::Array< TInternalComputationValueType >
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::VirtualImagePointer
typename VirtualImageType::Pointer VirtualImagePointer
Definition: itkObjectToObjectMetric.h:138
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itk::Point
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:53
itk::ObjectToObjectMetric
Computes similarity between regions of two objects.
Definition: itkObjectToObjectMetric.h:92
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:88
itk::Transform
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:83
itkPointSet.h
itkTransform.h
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::VirtualPixelType
typename VirtualImageType::PixelType VirtualPixelType
Definition: itkObjectToObjectMetric.h:140
itk::Array2D
Array2D class representing a 2D array.
Definition: itkArray2D.h:42
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::VirtualSizeType
typename VirtualRegionType::SizeType VirtualSizeType
Definition: itkObjectToObjectMetric.h:142
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::FixedTransformJacobianType
typename FixedTransformType::JacobianType FixedTransformJacobianType
Definition: itkObjectToObjectMetric.h:170
itk::ObjectToObjectMetric::GetMetricCategory
MetricCategoryType GetMetricCategory() const override
Definition: itkObjectToObjectMetric.h:322