18#ifndef __registration_metric_demons_cc_h__
19#define __registration_metric_demons_cc_h__
29 namespace Registration
34 template <
class Im1ImageType,
class Im2ImageType,
class Im1MaskType,
class Im2MaskType>
38 const Im1ImageType& im1_meansubtracted,
const Im2ImageType& im2_meansubtracted,
const Im1MaskType
im1_mask,
const Im2MaskType
im2_mask) :
43 mutex (
new std::mutex),
51 for (
size_t d = 0; d < 3; ++d)
52 normaliser += im1_meansubtracted.spacing(d) * im2_meansubtracted.spacing(d);
57 std::lock_guard<std::mutex> lock (*
mutex);
70 void operator() (
const Im1ImageType& im1_meansubtracted,
71 const Im2ImageType& im2_meansubtracted,
72 const Im2ImageType& A,
73 const Im2ImageType& B,
74 const Im2ImageType& C,
78 if (im1_meansubtracted.index(0) == 0 || im1_meansubtracted.index(0) == im1_meansubtracted.size(0) - 1 ||
79 im1_meansubtracted.index(1) == 0 || im1_meansubtracted.index(1) == im1_meansubtracted.size(1) - 1 ||
80 im1_meansubtracted.index(2) == 0 || im1_meansubtracted.index(2) == im1_meansubtracted.size(2) - 1) {
81 im1_update.row(3) = 0.0;
82 im2_update.row(3) = 0.0;
88 assign_pos_of (im1_meansubtracted, 0, 3).to (
im1_mask);
90 if (im1_mask_value < 0.1) {
91 im1_update.row(3) = 0.0;
92 im2_update.row(3) = 0.0;
99 assign_pos_of (im2_meansubtracted, 0, 3).to (
im2_mask);
101 if (im2_mask_value < 0.1) {
102 im1_update.row(3) = 0.0;
103 im2_update.row(3) = 0.0;
117 im1_update.row(3) = 0.0;
118 im2_update.row(3) = 0.0;
132 Eigen::Matrix<typename Im1ImageType::value_type, 3, 1> grad = 2.0 * sfm / (sff * smm) * (
136 im1_update.row(3) = grad * 40.0;
137 im2_update.row(3) = -grad * 40.0;
Adapter::Gradient3D< Im1ImageType > im1_gradient
const default_type intensity_difference_threshold
std::shared_ptr< std::mutex > mutex
default_type & global_cost
const default_type denominator_threshold
size_t & global_voxel_count
Adapter::Gradient3D< Im2ImageType > im2_gradient
size_t thread_voxel_count
const default_type robustness_parameter
MR::default_type value_type
double default_type
the default type used throughout MRtrix
constexpr std::enable_if< std::is_arithmetic< X >::value &&std::is_unsigned< X >::value, X >::type abs(X x)