| 58 | |
| 59 | |
| 60 | int |
| 61 | main(int argc, char * argv[]) |
| 62 | { |
| 63 | |
| 64 | if (argc < 4) |
| 65 | { |
| 66 | std::cerr << "Usage: " << argv[0] << " <fixedImageFilter> <movingImageFile> <outputTransformFile>" << std::endl; |
| 67 | return 1; |
| 68 | } |
| 69 | |
| 70 | |
| 71 | sitk::Image fixed = sitk::ReadImage(argv[1], sitk::sitkFloat32); |
| 72 | fixed = sitk::Normalize(fixed); |
| 73 | fixed = sitk::DiscreteGaussian(fixed, 2.0); |
| 74 | |
| 75 | sitk::Image moving = sitk::ReadImage(argv[2], sitk::sitkFloat32); |
| 76 | moving = sitk::Normalize(moving); |
| 77 | moving = sitk::DiscreteGaussian(moving, 2.0); |
| 78 | |
| 79 | |
| 80 | sitk::ImageRegistrationMethod R; |
| 81 | R.SetMetricAsJointHistogramMutualInformation(); |
| 82 | |
| 83 | const double learningRate = 1; |
| 84 | const unsigned int numberOfIterations = 200; |
| 85 | const double convergenceMinimumValue = 1e-4; |
| 86 | const unsigned int convergenceWindowSize = 5; |
| 87 | R.SetOptimizerAsGradientDescentLineSearch( |
| 88 | learningRate, numberOfIterations, convergenceMinimumValue, convergenceWindowSize); |
| 89 | |
| 90 | R.SetInitialTransform(sitk::TranslationTransform(fixed.GetDimension())); |
| 91 | R.SetInterpolator(sitk::sitkLinear); |
| 92 | |
| 93 | IterationUpdate cmd(R); |
| 94 | R.AddCommand(sitk::sitkIterationEvent, cmd); |
| 95 | |
| 96 | sitk::Transform outTx = R.Execute(fixed, moving); |
| 97 | |
| 98 | std::cout << "-------" << std::endl; |
| 99 | std::cout << outTx.ToString() << std::endl; |
| 100 | std::cout << "Optimizer stop condition: " << R.GetOptimizerStopConditionDescription() << std::endl; |
| 101 | std::cout << " Iteration: " << R.GetOptimizerIteration() << std::endl; |
| 102 | std::cout << " Metric value: " << R.GetMetricValue() << std::endl; |
| 103 | |
| 104 | sitk::WriteTransform(outTx, argv[3]); |
| 105 | |
| 106 | |
| 107 | return 0; |
| 108 | } |
nothing calls this directly
no test coverage detected