21 parser = argparse.ArgumentParser(description=
"Convert vtk Image Data To An itk Image.")
22 parser.add_argument(
"input_image")
23 args = parser.parse_args()
27 ImageType =
itk.Image[PixelType, Dimension]
29 reader = vtk.vtkPNGReader()
30 reader.SetFileName(args.input_image)
31 reader.SetDataScalarTypeToUnsignedChar()
33 magnitude = vtk.vtkImageMagnitude()
34 magnitude.SetInputConnection(reader.GetOutputPort())
38 vtkToItkFilter.SetInput(magnitude.GetOutput())
40 vtkToItkFilter.Update()
41 myitkImage = vtkToItkFilter.GetOutput()