/usr/include/ITK-4.5/itkObjectToObjectMultiMetricv4.h is in libinsighttoolkit4-dev 4.5.0-3.
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 | /*=========================================================================
*
* 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 __itkObjectToObjectMultiMetricv4_h
#define __itkObjectToObjectMultiMetricv4_h
#include "itkObjectToObjectMetric.h"
#include "itkArray.h"
#include <deque>
namespace itk
{
/** \class ObjectToObjectMultiMetricv4
* \brief This class takes one ore more ObjectToObject metrics and assigns weights to their derivatives
* to compute a single result.
*
* This class takes N ObjectToObject-derived component metrics and assigns a weight to each of the metrics'
* derivatives. It then computes a weighted measure of the metric. The GetValue() and
* GetValueAndDerivative() methods compute the measure and derivative using the following calculation:
*
* metric value = Sum_j ( w_j * M_j ) (see important note below)
*
* and the GetDerivative() method computes the derivative by computing:
*
* derivative = Sum_j ( w_j * dM_j / ||dM_j|| ) * ( Sum_j( ||dM_j|| ) / J )
*
* \note The metric value is unit-less, and thus it is difficult to compute a combined metric.
* This metric returns the metric value in three ways:
* 1) GetValue() returns the computed value of only the *first* component metric. This result
* is stored in m_Value and also returned by GetCurrentValue().
* 2) GetValueArray() returns an itkArray of metric values, one for each component metric. It
* only has meaning after a call to GetValue(), GetDerivative() or GetValueAndDerivative().
* 3) GetWeightedValue() returns a combined metric value of all component metrics, using the
* assigned weights. It only has meaning after a call to GetValue(), GetDerivative()
* or GetValueAndDerivative().
*
* The assigned weights are normalized internally to sum to one before use, and the weights
* default to 1/N, where N is the number of component metrics.
*
* \note Each component metric must use the same transform parameters object. That is, each metric
* must be evaluating the same parameters by evaluating the same transform. Except, if a component
* transform is a CompositeTransform, in which case it must be set to optimize a single transform,
* and that transform must be the same as the transform in other component metrics.
*
* \note Each component metric must be setup independently, except for the metric transforms
* which can optionally be set from this class. That is, each component's images or point sets,
* fixed transforms and options must be set independently. The only methods in this metric for setting
* up the component metrics is SetMovingTransform(). The corresponding
* Set accesor is also available. When Set{Fixed/Moving}Transform() is not used
* this metric's m_{Fixed/Moving}Transform member is assigned to the
* fixed/moving transform assigned to the first component metric.
*
* Each component will be initialized by this metric in the call to Initialize().
*
* \note When used with an itkRegistrationParameterScalesEstimator estimator, and the multi-metric
* holds one or more point-set metrics, the user must assign a virtual domain point set for sampling
* to ensure proper sampling within the point set metrics. In order to generate valid shift estimations,
* such a virtual domain point set must include mapped points from the fixed point set.
* See RegistrationParameterScalesEstimator::SetVirtualDomainPointSet() and
* PointSetToPointSetMetricv4::GetVirtualTransformedPointSet(). If there are two different point sets,
* then the virtual domain point set should be a union of the two for completeness.
*
* \note If the user does not explicitly assign a virtual domain, then the first valid virtual
* domain found in the component metrics will be used a virtual domain for this multi-metric,
* which will be queried by classes such as registration parameter estimators.
* Each componenet metric will still use its own virtual domain for internal calculations when
* evaluated, so it is possible to use different virtual domains for each metric if desired.
* If no component metric has a virtual domain defined, then by default the virtual domain is
* unbounded.
* When the transform is high dimensional (e.g. DisplacementFieldTransform) then there must
* be a virtual domain that matches the space of the transform field. Note that when used
* with a DisplacementFieldTransform, both Image and PointSet metrics will automatically
* create a matching virtual domain during initialization if one has not been assigned by the user.
*
* \ingroup ITKMetricsv4
*/
template<unsigned int TFixedDimension, unsigned int TMovingDimension, typename TVirtualImage = Image<double, TFixedDimension>, class TInternalComputationValueType = double >
class ObjectToObjectMultiMetricv4:
public ObjectToObjectMetric<TFixedDimension, TMovingDimension, TVirtualImage, TInternalComputationValueType>
{
public:
/** Standard class typedefs */
typedef ObjectToObjectMultiMetricv4 Self;
typedef ObjectToObjectMetric<TFixedDimension, TMovingDimension, TVirtualImage, TInternalComputationValueType> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
/** Run-time type information (and related methods). */
itkTypeMacro(ObjectToObjectMultiMetricv4, ObjectToObjectMetric);
/** New macro for creation of through a Smart Pointer */
itkNewMacro( Self );
/** Types inherited from Superclass. */
typedef typename Superclass::MeasureType MeasureType;
typedef typename Superclass::DerivativeType DerivativeType;
typedef typename Superclass::DerivativeValueType DerivativeValueType;
typedef typename Superclass::ParametersType ParametersType;
typedef typename Superclass::ParametersValueType ParametersValueType;
typedef typename Superclass::NumberOfParametersType NumberOfParametersType;
typedef typename Superclass::CoordinateRepresentationType CoordinateRepresentationType;
typedef typename Superclass::MovingTransformType MovingTransformType;
typedef typename Superclass::FixedTransformType FixedTransformType;
/** typedefs related to the metric queue */
typedef Superclass MetricType;
typedef typename MetricType::Pointer MetricBasePointer;
typedef typename MetricType::ConstPointer MetricBaseConstPointer;
typedef std::deque<MetricBasePointer> MetricQueueType;
typedef typename DerivativeType::ValueType WeightValueType;
typedef Array<WeightValueType> WeightsArrayType;
typedef Array<MeasureType> MetricValueArrayType;
itkSetMacro(MetricWeights,WeightsArrayType);
itkGetMacro(MetricWeights,WeightsArrayType);
/** Add a metric to the queue */
void AddMetric( MetricType* metric );
/** Clear the metric queue */
void ClearMetricQueue( void );
/** Get the number of metrics */
SizeValueType GetNumberOfMetrics() const;
void Initialize(void) throw ( itk::ExceptionObject );
/** Set each of the component metrics to use this moving transform. */
virtual void SetMovingTransform( MovingTransformType * );
/** Set each of the component metrics to use this fixed transform. */
virtual void SetFixedTransform( FixedTransformType * );
/** Evaluate the metrics and return the value of only the *first* metric.
* \sa GetValueArray
* \sa GetWeightedValue
*/
MeasureType GetValue() const;
virtual void GetDerivative( DerivativeType & ) const;
/** Evaluate the metric value and derivative.
* \note \param value will contain the value of only the *first* metric on return.
* \param derivative holds the combined derivative on return.
*
* \sa GetValueArray
* \sa GetWeightedValue */
void GetValueAndDerivative(MeasureType & value, DerivativeType & derivative) const;
/** Returns an itkArray of metric values, one for each component metric. It
* only has meaning after a call to GetValue(), GetDerivative() or GetValueAndDerivative(). */
MetricValueArrayType GetValueArray() const;
/** Returns a combined metric value of all component metrics, using the
* assigned weights. It only has meaning after a call to GetValue(), GetDerivative() or GetValueAndDerivative(). */
MeasureType GetWeightedValue() const;
/** Get the metrics queue */
const MetricQueueType & GetMetricQueue() const;
virtual bool SupportsArbitraryVirtualDomainSamples( void ) const;
protected:
ObjectToObjectMultiMetricv4();
virtual ~ObjectToObjectMultiMetricv4();
void PrintSelf(std::ostream & os, Indent indent) const;
private:
//purposely not implemented
ObjectToObjectMultiMetricv4(const Self &);
void operator=(const Self &);
MetricQueueType m_MetricQueue;
WeightsArrayType m_MetricWeights;
mutable MetricValueArrayType m_MetricValueArray;
};
} //end namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
#include "itkObjectToObjectMultiMetricv4.hxx"
#endif
#endif
|