# available if you built ITK with ITK_CSWIG_CONNECTVTKITK set to ON. CVIPy.ConnectVTKToITKF2(vtkExporter, itkImporter.GetPointer()) # perform a canny edge detection and rescale the output canny = itk.itkCannyEdgeDetectionImageFilterF2F2_New() rescaler = itk.itkRescaleIntensityImageFilterF2US2_New() canny.SetInput(itkImporter.GetOutput()) rescaler.SetInput(canny.GetOutput()) rescaler.SetOutputMinimum(0) rescaler.SetOutputMaximum(65535) # this is to show off the new PyCommand functionality. :) def progressEvent(): print "%.0f%s done..." % (canny.GetProgress() * 100.0, '%') pc = itk.itkPyCommand_New() pc.SetCommandCallable(progressEvent) canny.AddObserver(itk.itkProgressEvent(), pc.GetPointer()) # end of show-off # this will form the end-point of the ITK pipeline segment itkExporter = itk.itkVTKImageExportUS2_New() itkExporter.SetInput(rescaler.GetOutput()) # the vtkImageImport will bring our data back into VTK-land vtkImporter = vtk.vtkImageImport() # do the magic connection call (once again: only available if you built # ITK with ITK_CSWIG_CONNECTVTKITK set to ON) CVIPy.ConnectITKUS2ToVTK(itkExporter.GetPointer(), vtkImporter) # finally write the image to disk using VTK
# available if you built ITK with ITK_CSWIG_CONNECTVTKITK set to ON. CVIPy.ConnectVTKToITKF2(vtkExporter, itkImporter.GetPointer()) # perform a canny edge detection and rescale the output canny = itk.itkCannyEdgeDetectionImageFilterF2F2_New() rescaler = itk.itkRescaleIntensityImageFilterF2US2_New() canny.SetInput(itkImporter.GetOutput()) rescaler.SetInput(canny.GetOutput()) rescaler.SetOutputMinimum(0) rescaler.SetOutputMaximum(65535) # this is to show off the new PyCommand functionality. :) def progressEvent(): print "%.0f%s done..." % (canny.GetProgress() * 100.0, '%') pc = itk.itkPyCommand_New() pc.SetCommandCallable(progressEvent) canny.AddObserver(itk.itkProgressEvent(), pc.GetPointer()) # end of show-off # this will form the end-point of the ITK pipeline segment itkExporter = itk.itkVTKImageExportUS2_New() itkExporter.SetInput(rescaler.GetOutput()) # the vtkImageImport will bring our data back into VTK-land vtkImporter = vtk.vtkImageImport() # do the magic connection call (once again: only available if you built # ITK with ITK_CSWIG_CONNECTVTKITK set to ON) CVIPy.ConnectITKUS2ToVTK(itkExporter, vtkImporter) # finally write the image to disk using VTK