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)
50 demons.SetNumberOfIterations( 50 )
52 demons.SetStandardDeviations( 1.0 )
54 demons.AddCommand( sitk.sitkIterationEvent,
lambda: command_iteration(demons) )
56 displacementField = demons.Execute( fixed, moving )
60 print(
"Number Of Iterations: {0}".format(demons.GetElapsedIterations()))
61 print(
" RMS: {0}".format(demons.GetRMSChange()))
67 if (
not "SITK_NOSHOW" in os.environ ):
70 resampler.SetReferenceImage(fixed);
71 resampler.SetInterpolator(sitk.sitkLinear)
72 resampler.SetDefaultPixelValue(100)
73 resampler.SetTransform(outTx)
75 out = resampler.Execute(moving)
82 sitk.Show( cimg,
"DeformableRegistration1 Composition" )