/usr/include/ITK-4.9/itkObjectToObjectMetricBase.h is in libinsighttoolkit4-dev 4.9.0-4ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | /*=========================================================================
*
* Copyright Insight Software Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef itkObjectToObjectMetricBase_h
#define itkObjectToObjectMetricBase_h
#include "itkTransformBase.h"
#include "itkSingleValuedCostFunctionv4.h"
namespace itk
{
/** \class ObjectToObjectMetricBaseTemplate
* \brief Base class for all object-to-object similarlity metrics added in ITKv4.
*
* This is the abstract base class for a hierarchy of similarity metrics
* that may, in derived classes, operate on meshes, images, etc.
* This class computes a value that measures the similarity between the two
* objects.
*
* Derived classes must provide implementations for:
* GetValue
* GetDerivative
* GetValueAndDerivative
* Initialize
* GetNumberOfParameters
* GetNumberOfLocalParameters
* GetParameters
* SetParameters
* HasLocalSupport
* UpdateTransformParameters
*
* \ingroup ITKOptimizersv4
*/
template<typename TInternalComputationValueType=double>
class ObjectToObjectMetricBaseTemplate:
public SingleValuedCostFunctionv4Template<TInternalComputationValueType>
{
public:
/** Standard class typedefs. */
typedef ObjectToObjectMetricBaseTemplate Self;
typedef SingleValuedCostFunctionv4Template<TInternalComputationValueType> Superclass;
typedef SmartPointer< Self > Pointer;
typedef SmartPointer< const Self > ConstPointer;
/** Run-time type information (and related methods). */
itkTypeMacro(ObjectToObjectMetricBaseTemplate, SingleValuedCostFunctionv4Template);
/** Type used for representing object components */
typedef TInternalComputationValueType CoordinateRepresentationType;
/** Type of the measure. */
typedef typename Superclass::MeasureType MeasureType;
/** Type of the derivative. */
typedef typename Superclass::DerivativeType DerivativeType;
typedef typename DerivativeType::ValueType DerivativeValueType;
/** Type of the parameters. */
typedef typename Superclass::ParametersType ParametersType;
typedef TInternalComputationValueType ParametersValueType;
/** Type of object. */
typedef Object ObjectType;
typedef typename ObjectType::ConstPointer ObjectConstPointer;
/** Get/Set the Fixed Object. */
itkSetConstObjectMacro( FixedObject, ObjectType );
itkGetConstObjectMacro( FixedObject, ObjectType );
/** Get/Set the Moving Object. */
itkSetConstObjectMacro( MovingObject, ObjectType );
itkGetConstObjectMacro( MovingObject, ObjectType );
/** Source of the gradient(s) used by the metric
* (e.g. image gradients, in the case of
* image to image metrics). Defaults to Moving. */
typedef enum { GRADIENT_SOURCE_FIXED=0,
GRADIENT_SOURCE_MOVING,
GRADIENT_SOURCE_BOTH } GradientSourceType;
/**
* Set source of gradient. This variable allows the user to switch
* between calculating the gradient with respect to the fixed
* object or moving object.
* \sa GradientSourceType
*/
itkSetMacro( GradientSource, GradientSourceType );
/**
* Get gradient source.
* See \c GetGradientSourceIncludesFixed and \c GetGradientSourceIncludesMoving
* for convenience methods. */
itkGetConstMacro( GradientSource, GradientSourceType );
/** Return true of \c m_GradientSource is either \c GRADIENT_SOURCE_FIXED or
* \c GRADIENT_SOURCE_BOTH. Convenience method. */
bool GetGradientSourceIncludesFixed() const;
/** Return true of \c m_GradientSource is either \c GRADIENT_SOURCE_MOVING or
* \c GRADIENT_SOURCE_BOTH. Convenience method. */
bool GetGradientSourceIncludesMoving() const;
/** Initialize the Metric by making sure that all the components
* are present and plugged together correctly, and initializing
* internal variables as required. This is for one-time initialization,
* e.g. before starting an optimization process. */
virtual void Initialize(void) throw ( ExceptionObject ) = 0;
/** Type to represent the number of parameters that are being optimized at
* any given iteration of the optimizer. */
typedef unsigned int NumberOfParametersType;
/** Calculate and return the value for the metric based on the current
* transformation(s). The result is both returned, and stored in the
* m_Value member variable. */
virtual MeasureType GetValue() const ITK_OVERRIDE = 0;
/**
* This method returns the derivative based on the current
* transformation(s). */
virtual void GetDerivative( DerivativeType & ) const = 0;
/** This method returns the derivative and value based on the current
* transformation(s). */
virtual void GetValueAndDerivative( MeasureType & value, DerivativeType & derivative ) const ITK_OVERRIDE = 0;
/** Methods for working with the metric's 'active' transform, e.g. the
* transform being optimized in the case of registration. Some of these are
* used in non-metric classes, e.g. optimizers. */
virtual NumberOfParametersType GetNumberOfParameters() const ITK_OVERRIDE = 0;
virtual NumberOfParametersType GetNumberOfLocalParameters() const = 0;
/** Set the active transform's parameters by value*/
virtual void SetParameters( ParametersType & params ) = 0;
/** Get a const reference to the active transform's parameters */
virtual const ParametersType & GetParameters() const = 0;
/** Return whether the metric's active transform has local support,
* e.g. whether it is dense/high-dimensional. */
virtual bool HasLocalSupport() const = 0;
/** Update the parameters of the metric's active transform.
* Typically this call is passed through directly to the transform.
* \c factor is a scalar multiplier for each value in update, and
* defaults to 1.0 .
* \c derivative must be the proper size, as retrieved
* from GetNumberOfParameters. */
virtual void UpdateTransformParameters( const DerivativeType & derivative,
ParametersValueType factor = NumericTraits<ParametersValueType>::OneValue()) = 0;
/** Get the current metric value stored in m_Value. This is only
* meaningful after a call to GetValue() or GetValueAndDerivative().
* Note that this would normally be called GetValue, but that name is
* used for historical reasons by GetValue() to compute the current
* metric value and store it in m_Value. */
MeasureType GetCurrentValue() const;
typedef enum {
UNKNOWN_METRIC = 0,
OBJECT_METRIC = 1,
IMAGE_METRIC = 2,
POINT_SET_METRIC = 3,
MULTI_METRIC = 4
} MetricCategoryType;
/** Get metric category */
virtual MetricCategoryType GetMetricCategory() const
{
return UNKNOWN_METRIC;
}
protected:
ObjectToObjectMetricBaseTemplate();
virtual ~ObjectToObjectMetricBaseTemplate();
void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
/** Fixed and Moving Objects */
ObjectConstPointer m_FixedObject;
ObjectConstPointer m_MovingObject;
GradientSourceType m_GradientSource;
/** Metric value, stored after evaluating */
mutable MeasureType m_Value;
private:
ObjectToObjectMetricBaseTemplate(const Self &) ITK_DELETE_FUNCTION;
void operator=(const Self &) ITK_DELETE_FUNCTION;
};
/** This helps to meet backward compatibility */
typedef ObjectToObjectMetricBaseTemplate<double> ObjectToObjectMetricBase;
} // end namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
#include "itkObjectToObjectMetricBase.hxx"
#endif
#endif
|