static void Main(string[] args) { if (args.Length < 3) { Console.WriteLine("Usage: %s <fixedImageFilter> <movingImageFile> <outputTransformFile>\n", "ImageRegistrationMethod2"); return; } ImageFileReader reader = new ImageFileReader(); reader.SetOutputPixelType(PixelIDValueEnum.sitkFloat32); reader.SetFileName(args[0]); Image fixedImage = reader.Execute(); fixedImage = SimpleITK.Normalize(fixedImage); SimpleITK.DiscreteGaussian(fixedImage, 2.0); reader.SetFileName(args[1]); Image movingImage = reader.Execute(); movingImage = SimpleITK.Normalize(movingImage); movingImage = SimpleITK.DiscreteGaussian(movingImage, 2.0); ImageRegistrationMethod R = new ImageRegistrationMethod(); R.SetMetricAsJointHistogramMutualInformation(); double learningRate = 1; uint numberOfIterations = 200; double convergenceMinimumValue = 1e-4; uint convergenceWindowSize = 5; R.SetOptimizerAsGradientDescentLineSearch(learningRate, numberOfIterations, convergenceMinimumValue, convergenceWindowSize); R.SetInitialTransform(new TranslationTransform(fixedImage.GetDimension())); R.SetInterpolator(InterpolatorEnum.sitkLinear); IterationUpdate cmd = new IterationUpdate(R); R.AddCommand(EventEnum.sitkIterationEvent, cmd); Transform outTx = R.Execute(fixedImage, movingImage); outTx.WriteTransform(args[2]); }