24 PixelType = itk.ctype(
"unsigned char")
25 ImageType =
itk.Image[PixelType, Dimension]
28 def create_fixed_image():
38 ImageType =
itk.Image[PixelType, Dimension]
39 image = ImageType.New()
40 image.SetRegions(region)
44 image[11:20, 11:20] = 255
46 itk.imwrite(image,
"fixedPython.png")
51 def create_moving_image():
61 ImageType =
itk.Image[PixelType, Dimension]
62 image = ImageType.New()
63 image.SetRegions(region)
67 image[51:60, 51:60] = 100
69 itk.imwrite(image,
"movingPython.png")
74 fixed_image = create_fixed_image()
75 moving_image = create_moving_image()
77 LandmarkPointType =
itk.Point[itk.D, Dimension]
78 LandmarkContainerType = itk.vector[LandmarkPointType]
80 fixed_landmarks = LandmarkContainerType()
81 moving_landmarks = LandmarkContainerType()
83 fixed_point = LandmarkPointType()
84 moving_point = LandmarkPointType()
90 fixed_landmarks.push_back(fixed_point)
91 moving_landmarks.push_back(moving_point)
97 fixed_landmarks.push_back(fixed_point)
98 moving_landmarks.push_back(moving_point)
104 fixed_landmarks.push_back(fixed_point)
105 moving_landmarks.push_back(moving_point)
110 transform_initializer = TransformInitializerType.New()
112 transform_initializer.SetFixedLandmarks(fixed_landmarks)
113 transform_initializer.SetMovingLandmarks(moving_landmarks)
116 transform_initializer.SetTransform(transform)
117 transform_initializer.InitializeTransform()
119 output = itk.resample_image_filter(
122 use_reference_image=
True,
123 reference_image=fixed_image,
124 default_pixel_value=200,
127 itk.imwrite(output,
"outputPython.png")