SparsityConstraint.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2013-2015 Imperial College London
5  * Copyright 2013-2015 Wenzhe Shi, 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_SparsityConstraint_H
21 #define MIRTK_SparsityConstraint_H
22 
23 #include "mirtk/TransformationConstraint.h"
24 
25 
26 namespace mirtk {
27 
28 
29 /**
30  * Sparsity contraint based on L1 norm of transformation parameters
31  *
32  * Wenzhe Shi et al., Registration using sparse free-form deformations,
33  * MICCAI 2012
34  *
35  * \sa http://link.springer.com/chapter/10.1007%2F978-3-642-33418-4_81
36  */
38 {
39  mirtkEnergyTermMacro(SparsityConstraint, EM_Sparsity);
40 
41 public:
42 
43  /// Constructor
44  SparsityConstraint(const char * = "");
45 
46  /// Evaluate gradient of energy term
47  ///
48  /// \param[in,out] gradient Gradient to which the evaluated gradient of this
49  /// energy term is added to with its resp. weight.
50  /// \param[in] step Step length for finite differences (unused).
51  /// \param[out] sgn_chg Whether sign change of parameter should be allowed.
52  void Gradient(double *gradient, double step, bool *sgn_chg = NULL);
53 
54  /// Adjust step length range
55  ///
56  /// \param[in] gradient Gradient of objective function.
57  /// \param[in,out] min Minimum step length.
58  /// \param[in,out] max Maximum step length.
59  virtual void GradientStep(const double *gradient, double &min, double &max) const;
60 
61 protected:
62 
63  /// Compute penalty for current transformation estimate
64  virtual double Evaluate();
65 
66  /// Compute gradient of penalty term w.r.t transformation parameters
67  virtual void EvaluateGradient(double *, double, double);
68 
69  /// Compute gradient of penalty term w.r.t transformation parameters
70  virtual void EvaluateGradient(double *, double, double, bool *);
71 
72 };
73 
74 
75 } // namespace mirtk
76 
77 #endif // MIRTK_SparsityConstraint_H
Default sparsity constraint.
virtual double Evaluate()
Compute penalty for current transformation estimate.
Definition: IOConfig.h:41
virtual void GradientStep(const double *gradient, double &min, double &max) const
SparsityConstraint(const char *="")
Constructor.
void Gradient(double *gradient, double step, bool *sgn_chg=NULL)
virtual void EvaluateGradient(double *, double, double)
Compute gradient of penalty term w.r.t transformation parameters.