PartialAffineTransformation.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2013-2015 Imperial College London
5  * Copyright 2013-2015 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_PartialAffineTransformation_H
21 #define MIRTK_PartialAffineTransformation_H
22 
23 #include "mirtk/AffineTransformation.h"
24 #include "mirtk/EventDelegate.h"
25 
26 
27 namespace mirtk {
28 
29 
30 /**
31  * Class for partial linear transformation.
32  *
33  * An instance of this class decorates either a rigid, similarity, or an
34  * affine transformation and represents only a fraction of this transformation,
35  * i.e., T(x) = A^t x = exp(t * log(A)) x. A negative fraction corresponds to
36  * the inverse transformation. The ParametricGradient function computes the
37  * update of the parameters of the decorated transformation. Instances of this
38  * class are used by the image registration filter for an inverse consistent
39  * and symmetric linear registration.
40  *
41  * Note: For a symmetric inverse consistent linear registration, the use of
42  * AffineTransformation and InverseAffineTransformation is more
43  * efficient then two PartialAffineTransformation instances.
44  * For example, use the \c ireg energy function setting
45  * "-NMI(I1 o T^-1, I2 o T)" instead of "-NMI(I1 o T^-0.5, I2 o T^0.5)".
46  * The resulting transformation has to be squared, i.e., applied twice
47  * to obtain the full transformation between I1 and I2, however.
48  *
49  * \sa InverseAffineTransformation
50  */
52 {
53  mirtkTransformationMacro(PartialAffineTransformation);
54 
55  // ---------------------------------------------------------------------------
56  // Attributes
57 
58  /// Pointer to decorated transformation
59  mirtkReadOnlyAggregateMacro(HomogeneousTransformation, Transformation);
60 
61  /// Fraction of decorated transformation, negative value corresponds to inverse
62  mirtkPublicAttributeMacro(double, Fraction);
63 
64  /// Observes changes of decorated transformation
65  EventDelegate _TransformationObserver;
66 
67  /// Update parameters and matrix after change of decorated transformation
68  void OnTransformationChanged();
69 
70 public:
71 
72  /// Set decorated rigid, similarity, or affine transformation
74 
75  // ---------------------------------------------------------------------------
76  // Construction/Destruction
77 
78  /// Constructor
80 
81  /// Destructor
83 
84  // ---------------------------------------------------------------------------
85  // Transformation parameters
86 
87  /// Checks whether transformation depends on the same vector of parameters
88  virtual bool HasSameDOFsAs(const class Transformation *) const;
89 
90  // ---------------------------------------------------------------------------
91  // Derivatives
92 
94 
95  /// Applies the chain rule to convert spatial non-parametric gradient
96  /// to a gradient w.r.t the parameters of this transformation
97  virtual void ParametricGradient(const GenericImage<double> *, double *,
98  const WorldCoordsImage * = NULL,
99  const WorldCoordsImage * = NULL,
100  double = 0, double = 1) const;
101 
102 };
103 
104 
105 } // namespace mirtk
106 
107 #endif // MIRTK_PartialAffineTransformation_H
Definition: IOConfig.h:41
virtual ~PartialAffineTransformation()
Destructor.
void Transformation(HomogeneousTransformation *)
Set decorated rigid, similarity, or affine transformation.
PartialAffineTransformation(HomogeneousTransformation *=NULL, double=1.0)
Constructor.
virtual void ParametricGradient(const GenericImage< double > *, double *, const WorldCoordsImage *=NULL, const WorldCoordsImage *=NULL, double=0, double=1) const
virtual bool HasSameDOFsAs(const class Transformation *) const
Checks whether transformation depends on the same vector of parameters.
virtual void ParametricGradient(const GenericImage< double > *, double *, const WorldCoordsImage *, const WorldCoordsImage *, double=NaN, double=1) const