ITK  5.1.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  * 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 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_ASSIGN(ObjectToObjectMetric);
96 
102 
105 
107  using CoordinateRepresentationType = TParametersValueType;
108 
110  using InternalComputationValueType = TParametersValueType;
111 
113  using MeasureType = typename Superclass::MeasureType;
114 
116  using ObjectType = typename Superclass::Object;
117 
119  using DerivativeType = typename Superclass::DerivativeType;
120  using DerivativeValueType = typename Superclass::DerivativeValueType;
121 
123  using ParametersType = typename Superclass::ParametersType;
124  using NumberOfParametersType = typename Superclass::NumberOfParametersType;
125 
126  using GradientSourceEnum = 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 
162 
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 
218 
234  void SetVirtualDomain(const VirtualSpacingType & spacing,
235  const VirtualOriginType & origin,
236  const VirtualDirectionType & direction,
237  const VirtualRegionType & region);
238 
241  void
242  SetVirtualDomainFromImage(const VirtualImageType * virtualImage);
243 
248  virtual bool
249  SupportsArbitraryVirtualDomainSamples() const = 0;
250 
256  virtual const TimeStamp &
257  GetVirtualDomainTimeStamp() const;
258 
262  GetVirtualSpacing() const;
263 
267  GetVirtualOrigin() const;
268 
272  GetVirtualDirection() const;
273 
276  const VirtualRegionType &
277  GetVirtualRegion() const;
278 
279  itkGetModifiableObjectMacro(VirtualImage, VirtualImageType);
280 
291  ComputeParameterOffsetFromVirtualIndex(const VirtualIndexType & index,
292  const NumberOfParametersType & numberOfLocalParameters) const;
293 
304  ComputeParameterOffsetFromVirtualPoint(const VirtualPointType & point,
305  const NumberOfParametersType & numberOfLocalParameters) const;
306 
311  bool
312  IsInsideVirtualDomain(const VirtualPointType & point) const;
313  bool
314  IsInsideVirtualDomain(const VirtualIndexType & index) const;
316 
317  using MetricCategoryType = typename Superclass::MetricCategoryEnum;
318 
321  GetMetricCategory() const override
322  {
323  return MetricCategoryType::OBJECT_METRIC;
324  }
325 
326 protected:
328  ~ObjectToObjectMetric() override = default;
329 
330  void
331  PrintSelf(std::ostream & os, Indent indent) const override;
332 
335  virtual void
336  VerifyDisplacementFieldSizeAndPhysicalSpace();
337 
338  bool
339  TransformPhysicalPointToVirtualIndex(const VirtualPointType &, VirtualIndexType &) const;
340  void
341  TransformVirtualIndexToPhysicalPoint(const VirtualIndexType &, VirtualPointType &) const;
342 
347  const MovingDisplacementFieldTransformType *
348  GetMovingDisplacementFieldTransform() const;
349 
356  bool
357  VerifyNumberOfValidPoints(MeasureType & value, DerivativeType & derivative) const;
358 
362 
364 
368 
372  mutable SizeValueType m_NumberOfValidPoints{ 0 };
373 };
374 } // end namespace itk
375 
376 #ifndef ITK_MANUAL_INSTANTIATION
377 # include "itkObjectToObjectMetric.hxx"
378 #endif
379 
380 #endif
itk::ObjectToObjectMetric::m_MovingTransform
MovingTransformPointer m_MovingTransform
Definition: itkObjectToObjectMetric.h:361
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
itk::ObjectToObjectMetric::m_UserHasSetVirtualDomain
bool m_UserHasSetVirtualDomain
Definition: itkObjectToObjectMetric.h:367
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:82
itk::ObjectToObjectMetricBaseTemplate::NumberOfParametersType
unsigned int NumberOfParametersType
Definition: itkObjectToObjectMetricBase.h:176
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
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::ObjectToObjectMetric::m_VirtualImage
VirtualImagePointer m_VirtualImage
Definition: itkObjectToObjectMetric.h:363
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::ObjectToObjectMetricBaseTemplate::DerivativeValueType
typename DerivativeType::ValueType DerivativeValueType
Definition: itkObjectToObjectMetricBase.h:113
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:86
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:59
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::MetricCategoryType
typename Superclass::MetricCategoryEnum MetricCategoryType
Definition: itkObjectToObjectMetric.h:317
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::JacobianType
typename FixedTransformType::JacobianType JacobianType
Definition: itkObjectToObjectMetric.h:169
itk::ObjectToObjectMetricBaseTemplateEnums::GradientSource
GradientSource
Definition: itkObjectToObjectMetricBase.h:40
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::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:106
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::InternalComputationValueType
TInternalComputationValueType InternalComputationValueType
Definition: itkObjectToObjectMetric.h:110
itkObjectToObjectMetricBase.h
itkObject.h
itk::ObjectToObjectMetricBaseTemplate::MeasureType
typename Superclass::MeasureType MeasureType
Definition: itkObjectToObjectMetricBase.h:109
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::VirtualImageConstPointer
typename VirtualImageType::ConstPointer VirtualImageConstPointer
Definition: itkObjectToObjectMetric.h:139
itk::Image::SpacingType
typename Superclass::SpacingType SpacingType
Definition: itkImage.h:154
itk::ObjectToObjectMetric::m_FixedTransform
FixedTransformPointer m_FixedTransform
Definition: itkObjectToObjectMetric.h:360
itk::Transform::ParametersType
typename Superclass::ParametersType ParametersType
Definition: itkTransform.h:121
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::ObjectToObjectMetric< TFixedPointSet::PointDimension, TMovingPointSet::PointDimension, Image< TInternalComputationValueType, TFixedPointSet::PointDimension >, TInternalComputationValueType >::VirtualSpacingType
typename VirtualImageType::SpacingType VirtualSpacingType
Definition: itkObjectToObjectMetric.h:143
itk::OffsetValueType
signed long OffsetValueType
Definition: itkIntTypes.h:94
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:60
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:86
itk::Transform
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:82
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 with size defined at construction time.
Definition: itkArray2D.h:45
itk::ObjectToObjectMetricBaseTemplate::DerivativeType
typename Superclass::DerivativeType DerivativeType
Definition: itkObjectToObjectMetricBase.h:112
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:83
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:321