private sitk.VectorOfParameterMap InvertTransformParameters(string parameterFilename) { sitk.Image fixedImage = ReadWriteUtils.ReadITKImageFromFile(registrationParameters.FixedImageFilename, sitk.PixelIDValueEnum.sitkFloat32); sitk.ElastixImageFilter elastix = null; try { // elastix manual 6.1.6: DisplacementMagnitudePenalty elastix = new sitk.ElastixImageFilter(); elastix.SetInitialTransformParameterFileName(parameterFilename); elastix.SetParameterMap(sitk.SimpleITK.GetDefaultParameterMap("rigid")); elastix.SetFixedImage(fixedImage); elastix.SetMovingImage(fixedImage); elastix.SetParameter("HowToCombineTransforms", "Compose"); elastix.SetParameter("Metric", "DisplacementMagnitudePenalty"); elastix.SetParameter("NumberOfResolutions", "1"); elastix.Execute(); return(elastix.GetTransformParameterMap()); /*sitk.TransformixImageFilter transformix = new sitk.TransformixImageFilter(); * transformix.SetTransformParameterMap(elastix.GetTransformParameterMap()); * transformix.SetTransformParameter("InitialTransformParametersFileName", "NoInitialTransform"); * transformix.Execute();*/ } catch (Exception ex) { Console.WriteLine(ex); return(null); } finally { elastix.Dispose(); fixedImage.Dispose(); } }
/// <summary> /// Get transform parameter map. /// </summary> /// <returns></returns> public virtual sitk.VectorOfParameterMap GetTransformationParameterMap() { if (elastix != null) { return(elastix.GetTransformParameterMap()); } return(null); }