20 from __future__
import print_function
22 import SimpleITK
as sitk
27 def command_iteration(filter) :
28 print(
"{0:3} = {1:10.5f}".format(filter.GetElapsedIterations(),
31 if len ( sys.argv ) < 4:
32 print(
"Usage: {0} <fixedImageFilter> <movingImageFile> <outputTransformFile>".format(sys.argv[0]))
42 matcher.SetNumberOfHistogramLevels(1024)
43 matcher.SetNumberOfMatchPoints(7)
44 matcher.ThresholdAtMeanIntensityOn()
45 moving = matcher.Execute(moving,fixed)
48 demons.SetNumberOfIterations( 50 )
49 demons.SetStandardDeviations( 1.0 )
51 demons.AddCommand( sitk.sitkIterationEvent,
lambda: command_iteration(demons) )
53 displacementField = demons.Execute( fixed, moving )
57 print(
"Number Of Iterations: {0}".format(demons.GetElapsedIterations()))
58 print(
" RMS: {0}".format(demons.GetRMSChange()))
64 if (
not "SITK_NOSHOW" in os.environ ):
67 resampler.SetReferenceImage(fixed);
68 resampler.SetInterpolator(sitk.sitkLinear)
69 resampler.SetDefaultPixelValue(100)
70 resampler.SetTransform(outTx)
72 out = resampler.Execute(moving)
76 sitk.Show( cimg,
"DeformableRegistration1 Composition" )