SumOfSquaredIntensityDifferences.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_SumOfSquaredIntensityDifferences_H
21 #define MIRTK_SumOfSquaredIntensityDifferences_H
22 
23 #include "mirtk/ImageSimilarity.h"
24 
25 
26 namespace mirtk {
27 
28 
29 /**
30  * Sum of squared differences image similarity measure
31  */
33 {
34  mirtkEnergyTermMacro(SumOfSquaredIntensityDifferences, EM_SSD);
35 
36  // ---------------------------------------------------------------------------
37  // Attributes
38 
39  /// Minimum input target image intensity value
40  mirtkReadOnlyAttributeMacro(double, MinTargetIntensity);
41 
42  /// Maximum input target image intensity value
43  mirtkReadOnlyAttributeMacro(double, MaxTargetIntensity);
44 
45  /// Minimum input source image intensity value
46  mirtkReadOnlyAttributeMacro(double, MinSourceIntensity);
47 
48  /// Maximum input source image intensity value
49  mirtkReadOnlyAttributeMacro(double, MaxSourceIntensity);
50 
51  /// Maximum squared intensity difference used for normalization
52  mirtkReadOnlyAttributeMacro(double, MaxSqDiff);
53 
54  /// Sum of squared intensity difference value
55  mirtkReadOnlyAttributeMacro(double, SumSqDiff);
56 
57  /// Number of foreground voxels for which similarity is evaluated
58  mirtkReadOnlyAttributeMacro(int, NumberOfForegroundVoxels);
59 
60  /// Copy attributes of this class from another instance
61  void CopyAttributes(const SumOfSquaredIntensityDifferences &);
62 
63  // ---------------------------------------------------------------------------
64  // Construction/Destruction
65 public:
66 
67  /// Constructor
68  SumOfSquaredIntensityDifferences(const char * = "");
69 
70  /// Copy constructor
72 
73  /// Assignment operator
75 
76  /// Destructor
78 
79  // ---------------------------------------------------------------------------
80  // Initialization
81 
82  /// Initialize similarity measure
83  virtual void Initialize();
84 
85  /// Update moving input image(s) and internal state of similarity measure
86  virtual void Update(bool = true);
87 
88  // ---------------------------------------------------------------------------
89  // Evaluation
90 protected:
91 
92  /// Exclude region from similarity evaluation
93  ///
94  /// Called by ApproximateGradient \b before the registered image region of
95  /// the transformed image is updated.
96  virtual void Exclude(const blocked_range3d<int> &);
97 
98  /// Include region in similarity evaluation
99  ///
100  /// Called by ApproximateGradient \b after the registered image region of
101  /// the transformed image is updated.
102  virtual void Include(const blocked_range3d<int> &);
103 
104  /// Evaluate similarity of images
105  virtual double Evaluate();
106 
107  /// Evaluate non-parametric similarity gradient w.r.t the given image
109 
110 };
111 
112 
113 } // namespace mirtk
114 
115 #endif // MIRTK_SumOfSquaredIntensityDifferences_H
virtual void Initialize()
Initialize similarity measure.
SumOfSquaredIntensityDifferences(const char *="")
Constructor.
virtual bool NonParametricGradient(const RegisteredImage *, GradientImageType *)
Evaluate non-parametric similarity gradient w.r.t the given image.
Definition: IOConfig.h:41
virtual double Evaluate()
Evaluate similarity of images.
virtual void Include(const blocked_range3d< int > &)
virtual void Exclude(const blocked_range3d< int > &)
Three-dimensional range.
Definition: Parallel.h:197
Sum of squared differences.
Definition: EnergyMeasure.h:43
SumOfSquaredIntensityDifferences & operator=(const SumOfSquaredIntensityDifferences &)
Assignment operator.
virtual void Update(bool=true)
Update moving input image(s) and internal state of similarity measure.