21 """ A SimpleITK example demonstrating filter progress reporting. """
26 import SimpleITK
as sitk
29 print(
"Usage: " + sys.argv[0] +
" <input> <variance> <output>")
35 """ Sample command class that prints the progress of the process object. """
36 def __init__(self, po):
37 """ Constructor, note that the base class constructor is called here. """
40 self.processObject = po
43 """ Method that is called by the process object. """
45 f
"{self.processObject.GetName()}"
46 + f
" Progress: {self.processObject.GetProgress():1.2f}"
53 reader.SetFileName(sys.argv[1])
54 image = reader.Execute()
56 pixelID = image.GetPixelID()
59 gaussian.SetVariance(float(sys.argv[2]))
62 gaussian.AddCommand(sitk.sitkStartEvent,
lambda: print(
"StartEvent"))
63 gaussian.AddCommand(sitk.sitkEndEvent,
lambda: print(
"EndEvent"))
66 cmd = MyCommand(gaussian)
67 gaussian.AddCommand(sitk.sitkProgressEvent, cmd)
69 image = gaussian.Execute(image)
72 caster.SetOutputPixelType(pixelID)
73 image = caster.Execute(image)
76 writer.SetFileName(sys.argv[3])
79 if "SITK_NOSHOW" not in os.environ: