SimilarityMeasure.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_SimilarityMeasure_H
21 #define MIRTK_SimilarityMeasure_H
22 
23 #include "mirtk/EnergyMeasure.h"
24 
25 
26 namespace mirtk {
27 
28 
29 // -----------------------------------------------------------------------------
30 /// Enumeration of available similarity measures
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  SIM_Unknown = SIM_Begin, ///< Unknown/invalid image (dis-)similarity measure
40  SIM_JE = EM_JE, ///< Joint entropy
41  SIM_CC = EM_CC, ///< Cross-correlation
42  SIM_MI = EM_MI, ///< Mutual information
43  SIM_NMI = EM_NMI, ///< Normalized mutual information
44  SIM_SSD = EM_SSD, ///< Sum of squared differences
45  SIM_CR_XY = EM_CR_XY, ///< Correlation ratio
46  SIM_CR_YX = EM_CR_YX, ///< Correlation ratio
47  SIM_LC = EM_LC, ///< Label consistency
48  SIM_K = EM_K, ///< Kappa statistic
49  SIM_ML = EM_ML, ///< Maximum likelihood
50  SIM_NGF_COS = EM_NGF_COS, ///< Cosine of normalzed gradient field
51  SIM_NCC = EM_NCC, ///< Normalized cross-correlation
52  SIM_LNCC = EM_LNCC, ///< Local normalized cross-correlation
53  SIM_CoVar = EM_CoVar, ///< Covariance
54  SIM_PSNR = EM_PSNR ///< Peak signal-to-noise ratio
55 };
56 
57 // -----------------------------------------------------------------------------
58 template <>
59 inline string ToString(const SimilarityMeasure &sim, int w, char c, bool left)
60 {
61  EnergyMeasure em = static_cast<EnergyMeasure>(sim);
62  if (em <= SIM_Begin || em >= SIM_End) return ToString("Unknown", w, c, left);
63  return ToString(em, w, c, left);
64 }
65 
66 // -----------------------------------------------------------------------------
67 inline string ToPrettyString(const SimilarityMeasure &sim, int w = 0, char c = ' ', bool left = true)
68 {
69  EnergyMeasure em = static_cast<EnergyMeasure>(sim);
70  if (em <= SIM_Begin || em >= SIM_End) return ToString("Unknown", w, c, left);
71  return ToPrettyString(em, w, c, left);
72 }
73 
74 // -----------------------------------------------------------------------------
75 template <>
76 inline bool FromString(const char *str, SimilarityMeasure &sim)
77 {
79  if (FromString(str, em) && SIM_Begin < em && em < SIM_End) {
80  sim = static_cast<SimilarityMeasure>(em);
81  return true;
82  } else {
83  sim = SIM_Unknown;
84  return false;
85  }
86 }
87 
88 
89 } // namespace mirtk
90 
91 #endif // MIRTK_SimilarityMeasure_H
Correlation ratio.
Local normalized cross-correlation.
Definition: EnergyMeasure.h:51
Joint entropy.
Cross-correlation.
Kappa statistic.
Definition: EnergyMeasure.h:47
Unknown/invalid image (dis-)similarity measure.
Cosine of normalzed gradient field.
Definition: EnergyMeasure.h:49
Local normalized cross-correlation.
string ToPrettyString(const EnergyMeasure &value, int w=0, char c=' ', bool left=true)
Convert energy measure enumeration value to human-friendly descriptive string.
Kappa statistic.
Correlation ratio.
Definition: EnergyMeasure.h:45
Normalized mutual information.
Label consistency.
Definition: EnergyMeasure.h:46
Definition: IOConfig.h:41
Peak signal-to-noise ratio.
Normalized cross-correlation.
Definition: EnergyMeasure.h:50
Covariance.
Definition: EnergyMeasure.h:52
Mutual information.
Sum of squared differences.
Definition: EnergyMeasure.h:43
string ToString(const EnergyMeasure &value, int w, char c, bool left)
Convert energy measure enumeration value to string.
Normalized mutual information.
Definition: EnergyMeasure.h:42
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
Cross-correlation.
Definition: EnergyMeasure.h:40
Unknown/invalid energy term.
Definition: EnergyMeasure.h:33
Sum of squared differences.
Mutual information.
Definition: EnergyMeasure.h:41
Correlation ratio.
Label consistency.
Maximum likelihood.
Definition: EnergyMeasure.h:48
Peak signal-to-noise ratio.
Definition: EnergyMeasure.h:53
Joint entropy.
Definition: EnergyMeasure.h:39
Correlation ratio.
Definition: EnergyMeasure.h:44
Normalized cross-correlation.
Maximum likelihood.
Cosine of normalzed gradient field.