ITK
5.2.0
Insight Toolkit
ITK
Modules
Numerics
Statistics
include
itkDistanceMetric.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 itkDistanceMetric_h
19
#define itkDistanceMetric_h
20
21
#include "
itkFunctionBase.h
"
22
#include "
itkMeasurementVectorTraits.h
"
23
24
namespace
itk
25
{
26
namespace
Statistics
27
{
47
template
<
typename
TVector>
48
class
ITK_TEMPLATE_EXPORT
DistanceMetric
:
public
FunctionBase
<TVector, double>
49
{
50
public
:
52
using
Self
=
DistanceMetric
;
53
using
Superclass
=
FunctionBase<TVector, double>
;
54
using
Pointer
=
SmartPointer<Self>
;
55
using
ConstPointer
=
SmartPointer<const Self>
;
56
58
using
MeasurementVectorType
= TVector;
59
64
using
MeasurementVectorSizeType
=
unsigned
int;
65
67
itkTypeMacro(
DistanceMetric
,
FunctionBase
);
68
69
using
OriginType
=
Array<double>
;
70
77
void
78
SetOrigin(
const
OriginType
& x);
79
80
itkGetConstReferenceMacro(Origin,
OriginType
);
81
84
double
85
Evaluate(
const
MeasurementVectorType
& x)
const override
= 0;
86
92
virtual
double
93
Evaluate(
const
MeasurementVectorType
& x1,
const
MeasurementVectorType
& x2)
const
= 0;
94
96
virtual
void
97
SetMeasurementVectorSize
(
MeasurementVectorSizeType
s)
98
{
99
// Test whether the vector type is resizable or not
100
MeasurementVectorType
m;
101
102
if
(
MeasurementVectorTraits::IsResizable
(m))
103
{
104
// then this is a resizable vector type
105
//
106
// if the new size is the same as the previou size, just return
107
if
(s == this->m_MeasurementVectorSize)
108
{
109
return
;
110
}
111
else
112
{
113
this->m_MeasurementVectorSize = s;
114
this->Modified();
115
}
116
}
117
else
118
{
119
// If this is a non-resizable vector type
120
MeasurementVectorType
m3;
121
MeasurementVectorSizeType
defaultLength =
NumericTraits<MeasurementVectorType>::GetLength
(m3);
122
// and the new length is different from the default one, then throw an
123
// exception
124
if
(defaultLength != s)
125
{
126
itkExceptionMacro(
"Attempting to change the measurement \
127
vector size of a non-resizable vector type"
);
128
}
129
}
130
}
131
133
itkGetConstMacro(MeasurementVectorSize, MeasurementVectorSizeType);
134
135
protected
:
136
DistanceMetric
();
137
~
DistanceMetric
()
override
=
default
;
138
void
139
PrintSelf(std::ostream & os,
Indent
indent)
const override
;
140
141
private
:
142
OriginType
m_Origin
;
143
145
MeasurementVectorSizeType
m_MeasurementVectorSize
;
146
};
// end of class
147
}
// end of namespace Statistics
148
}
// end of namespace itk
149
150
#ifndef ITK_MANUAL_INSTANTIATION
151
# include "itkDistanceMetric.hxx"
152
#endif
153
154
#endif
itk::Statistics::DistanceMetric
this class declares common interfaces for distance functions.
Definition:
itkDistanceMetric.h:48
itk::Statistics::DistanceMetric::m_MeasurementVectorSize
MeasurementVectorSizeType m_MeasurementVectorSize
Definition:
itkDistanceMetric.h:145
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition:
itkIndent.h:49
itk::Statistics::DistanceMetric< Array< double > >::MeasurementVectorSizeType
unsigned int MeasurementVectorSizeType
Definition:
itkDistanceMetric.h:64
itkFunctionBase.h
itk::LightObject
Light weight base class for most itk classes.
Definition:
itkLightObject.h:59
itk::FunctionBase
Base class for all ITK function objects.
Definition:
itkFunctionBase.h:44
itkMeasurementVectorTraits.h
itk::Statistics::MeasurementVectorTraits::IsResizable
static bool IsResizable(const TVectorType &)
Definition:
itkMeasurementVectorTraits.h:62
itk::Statistics::DistanceMetric::m_Origin
OriginType m_Origin
Definition:
itkDistanceMetric.h:142
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition:
itkAnnulusOperator.h:24
itk::NumericTraits::GetLength
static unsigned int GetLength()
Definition:
itkNumericTraits.h:208
itk::Array< double >
itk::Statistics::DistanceMetric::SetMeasurementVectorSize
virtual void SetMeasurementVectorSize(MeasurementVectorSizeType s)
Definition:
itkDistanceMetric.h:97
Generated on Thu Apr 1 2021 01:41:29 for ITK by
1.8.16