| 197 | |
| 198 | |
| 199 | TEST_F(sitkRegistrationMethodTest, Metric_Evaluate) |
| 200 | { |
| 201 | sitk::Image fixed = fixedBlobs; |
| 202 | sitk::Image moving = fixedBlobs; |
| 203 | |
| 204 | sitk::ImageRegistrationMethod R; |
| 205 | R.SetInitialTransform(sitk::Transform(fixed.GetDimension(), sitk::sitkIdentity)); |
| 206 | |
| 207 | EXPECT_NEAR(-1.5299437083119216, R.MetricEvaluate(fixed, moving), 1e-10); |
| 208 | |
| 209 | R.SetMetricAsCorrelation(); |
| 210 | EXPECT_NEAR(-1.0, R.MetricEvaluate(fixed, moving), 1e-10); |
| 211 | |
| 212 | // tolerance adjusted for i386, why is it so much more? |
| 213 | R.SetMetricAsJointHistogramMutualInformation(20, 1.5); |
| 214 | EXPECT_NEAR(-0.52624100016564002, R.MetricEvaluate(fixed, moving), 2e-6); |
| 215 | |
| 216 | R.SetMetricAsMeanSquares(); |
| 217 | EXPECT_NEAR(0.0, R.MetricEvaluate(fixed, moving), 1e-10); |
| 218 | |
| 219 | R.SetMetricAsMattesMutualInformation(); |
| 220 | EXPECT_NEAR(-1.5299437083119216, R.MetricEvaluate(fixed, moving), 1e-10); |
| 221 | |
| 222 | R.SetMetricAsMeanSquares(); |
| 223 | |
| 224 | // test that the transforms are used |
| 225 | |
| 226 | R.SetInitialTransform(sitk::TranslationTransform(fixed.GetDimension(), v2(5, -7))); |
| 227 | EXPECT_NEAR(0.0036468516797954148, R.MetricEvaluate(fixed, moving), 1e-10); |
| 228 | |
| 229 | R.SetMovingInitialTransform(sitk::TranslationTransform(fixed.GetDimension(), v2(-5, 7))); |
| 230 | EXPECT_NEAR(0.0, R.MetricEvaluate(fixed, moving), 1e-10); |
| 231 | |
| 232 | R.SetFixedInitialTransform(sitk::TranslationTransform(fixed.GetDimension(), v2(-5, 7))); |
| 233 | EXPECT_NEAR(0.0036468516797954148, R.MetricEvaluate(fixed, moving), 1e-10); |
| 234 | |
| 235 | sitk::ImageRegistrationMethod R2; |
| 236 | R2.SetInitialTransform(sitk::Transform(fixed.GetDimension(), sitk::sitkIdentity)); |
| 237 | R2.SetMetricAsMeanSquares(); |
| 238 | R2.SetMetricFixedMask(sitk::Greater(fixedBlobs, 0)); |
| 239 | EXPECT_NEAR(0.0091550861657971119, R2.MetricEvaluate(fixedBlobs, movingBlobs), 1e-10); |
| 240 | |
| 241 | sitk::ImageRegistrationMethod R3; |
| 242 | R3.SetInitialTransform(sitk::Transform(fixed.GetDimension(), sitk::sitkIdentity)); |
| 243 | R3.SetMetricAsMeanSquares(); |
| 244 | R3.SetMetricMovingMask(sitk::Less(movingBlobs, 0)); |
| 245 | EXPECT_NEAR(3.34e-09, R3.MetricEvaluate(fixedBlobs, movingBlobs), 1e-10); |
| 246 | } |
| 247 | |
| 248 | TEST_F(sitkRegistrationMethodTest, Transform_InPlaceOn) |
| 249 | { |
nothing calls this directly
no test coverage detected