1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21""" A SimpleITK example demonstrating filter progress reporting. """
22
23import os
24import sys
25
26import SimpleITK as sitk
27
28if len(sys.argv) < 4:
29 print("Usage: " + sys.argv[0] + " <input> <variance> <output>")
30 sys.exit(1)
31
32
33
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. """
38
39 super().__init__()
40 self.processObject = po
41
42 def Execute(self):
43 """ Method that is called by the process object. """
44 print(
45 f"{self.processObject.GetName()}"
46 + f" Progress: {self.processObject.GetProgress():1.2f}"
47 )
48
49
50
51
53reader.SetFileName(sys.argv[1])
54image = reader.Execute()
55
56pixelID = image.GetPixelID()
57
59gaussian.SetVariance(float(sys.argv[2]))
60
61
62gaussian.AddCommand(sitk.sitkStartEvent, lambda: print("StartEvent"))
63gaussian.AddCommand(sitk.sitkEndEvent, lambda: print("EndEvent"))
64
65
66cmd = MyCommand(gaussian)
67gaussian.AddCommand(sitk.sitkProgressEvent, cmd)
68
69image = gaussian.Execute(image)
70
72caster.SetOutputPixelType(pixelID)
73image = caster.Execute(image)
74
76writer.SetFileName(sys.argv[3])
77writer.Execute(image)
78
79if "SITK_NOSHOW" not in os.environ:
A hybrid cast image filter to convert images to other types of images.
An implementation of the Command design pattern for callback.
Blurs an image by separable convolution with discrete gaussian kernels. This filter performs Gaussian...
Read an image file and return a SimpleITK Image.
Write out a SimpleITK image to the specified file location.
void SITKIO_EXPORT Show(const Image &image, const std::string &title="", const bool debugOn=ProcessObject::GetGlobalDefaultDebug())