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 writer = vtk.vtkPNGWriter() writer.SetFileName('./testout.png') writer.SetInput(vtkImporter.GetOutput()) # before we call Write() on the writer, it is prudent to give # our ITK pipeline an Update() call... this is not necessary
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 writer = vtk.vtkPNGWriter() writer.SetFileName('./testout.png') writer.SetInput(vtkImporter.GetOutput()) # before we call Write() on the writer, it is prudent to give # our ITK pipeline an Update() call... this is not necessary