17#ifndef __registration_metric_demons_h__
18#define __registration_metric_demons_h__
27 namespace Registration
32 template <
class Im1ImageType,
class Im2ImageType,
class Im1MaskType,
class Im2MaskType>
36 const Im1ImageType& im1_image,
const Im2ImageType& im2_image,
const Im1MaskType
im1_mask,
const Im2MaskType
im2_mask) :
41 mutex (
new std::mutex),
49 for (
size_t d = 0; d < 3; ++d)
50 normaliser += im1_image.spacing(d) * im2_image.spacing(d);
55 std::lock_guard<std::mutex> lock (*
mutex);
69 void operator() (
const Im1ImageType& im1_image,
70 const Im2ImageType& im2_image,
74 if (im1_image.index(0) == 0 || im1_image.index(0) == im1_image.size(0) - 1 ||
75 im1_image.index(1) == 0 || im1_image.index(1) == im1_image.size(1) - 1 ||
76 im1_image.index(2) == 0 || im1_image.index(2) == im1_image.size(2) - 1) {
77 im1_update.row(3) = 0.0;
78 im2_update.row(3) = 0.0;
84 assign_pos_of (im1_image, 0, 3).to (
im1_mask);
86 if (im1_mask_value < 0.1) {
87 im1_update.row(3) = 0.0;
88 im2_update.row(3) = 0.0;
95 assign_pos_of (im2_image, 0, 3).to (
im2_mask);
97 if (im2_mask_value < 0.1) {
98 im1_update.row(3) = 0.0;
99 im2_update.row(3) = 0.0;
105 default_type speed = im2_image.value() - im1_image.value();
115 Eigen::Matrix<typename Im1ImageType::value_type, 3, 1> grad = (
im2_gradient.value() +
im1_gradient.value()).array() / 2.0;
118 im1_update.row(3) = 0.0;
119 im2_update.row(3) = 0.0;
121 im1_update.row(3) = Eigen::Vector3d (speed * grad.array() / denominator);
122 im2_update.row(3) = -Eigen::Vector3d (im1_update.row(3));
Adapter::Gradient3D< Im1ImageType > im1_gradient
std::shared_ptr< std::mutex > mutex
const default_type denominator_threshold
default_type & global_cost
Adapter::Gradient3D< Im2ImageType > im2_gradient
const default_type intensity_difference_threshold
const default_type robustness_parameter
size_t & global_voxel_count
size_t thread_voxel_count
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)