ConstraintMeasure.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2013-2017 Imperial College London
5  * Copyright 2013-2017 Andreas Schuh
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #ifndef MIRTK_ConstraintMeasure_H
21 #define MIRTK_ConstraintMeasure_H
22 
23 #include "mirtk/EnergyMeasure.h"
24 
25 
26 namespace mirtk {
27 
28 
29 // -----------------------------------------------------------------------------
30 /// Enumeration of available transformation regularization terms
31 ///
32 /// \note This enumeration constains only a subset of all EnergyMeasure
33 /// enumeration values, whereby the integer value of corresponding
34 /// enumeration values is equal.
35 ///
36 /// \sa EnergyMeasure
38 {
39  CM_Unknown = CM_Begin, ///< Unknown/invalid regularizer
40  CM_VolumePreservation = EM_VolumePreservation, ///< Volume preservation constraint
41  CM_TopologyPreservation = EM_TopologyPreservation, ///< Topology preservation constraint
42  CM_Sparsity = EM_Sparsity, ///< Default sparsity constraint
43  CM_BendingEnergy = EM_BendingEnergy, ///< Thin-plate spline bending energy
44  CM_LinearElasticity = EM_LinearElasticity, ///< Linear elastic energy
45  CM_L0Norm = EM_L0Norm, ///< Sparsity constraint based on l0-norm
46  CM_L1Norm = EM_L1Norm, ///< Sparsity constraint based on l1-norm
47  CM_L2Norm = EM_L2Norm, ///< Sparsity constraint based on l2-norm
48  CM_SqLogDetJac = EM_SqLogDetJac, ///< Squared logarithm of the Jacobian determinant
49  CM_NegDetJac = EM_NegDetJac ///< Penalize negative Jacobian determinant
50 };
51 
52 // -----------------------------------------------------------------------------
53 template <>
54 inline string ToString(const ConstraintMeasure &cm, int w, char c, bool left)
55 {
56  EnergyMeasure em = static_cast<EnergyMeasure>(cm);
57  if (em <= CM_Begin || em >= CM_End) return ToString("Unknown", w, c, left);
58  return ToString(em, w, c, left);
59 }
60 
61 // -----------------------------------------------------------------------------
62 template <>
63 inline bool FromString(const char *str, ConstraintMeasure &cm)
64 {
66  if (FromString(str, em) && CM_Begin < em && em < CM_End) {
67  cm = static_cast<ConstraintMeasure>(em);
68  return true;
69  } else {
70  cm = CM_Unknown;
71  return false;
72  }
73 }
74 
75 
76 } // namespace mirtk
77 
78 #endif // MIRTK_ConstraintMeasure_H
Topology preservation constraint.
Sparsity constraint based on l2-norm.
Thin-plate spline bending energy.
Default sparsity constraint.
Sparsity constraint based on l1-norm.
Default sparsity constraint.
Sparsity constraint based on l0-norm.
Penalise negative Jacobian determinant.
Definition: IOConfig.h:41
Thin-plate spline bending energy.
Linear elastic energy.
Sparsity constraint based on l0-norm.
Sparsity constraint based on l2-norm.
Squared logarithm of the Jacobian determinant.
string ToString(const EnergyMeasure &value, int w, char c, bool left)
Convert energy measure enumeration value to string.
bool FromString(const char *str, EnergyMeasure &value)
Convert energy measure string to enumeration value.
EnergyMeasure
Enumeration of all available energy terms.
Definition: EnergyMeasure.h:31
Penalize negative Jacobian determinant.
Unknown/invalid energy term.
Definition: EnergyMeasure.h:33
Sparsity constraint based on l1-norm.
Volume preservation constraint.
Definition: EnergyMeasure.h:98
Linear elastic energy.
Volume preservation constraint.
Unknown/invalid regularizer.
Squared logarithm of the Jacobian determinant.
Topology preservation constraint.
Definition: EnergyMeasure.h:99