20 """ An example script showing the use of the ConnectedThresholdImageFilter """
24 import SimpleITK
as sitk
31 "Usage: ConnectedThresholdImageFilter inputImage outputImage",
32 "lowerThreshold upperThreshold seedX seedY [seed2X seed2Y ... ]",
40 reader.SetFileName(sys.argv[1])
41 image = reader.Execute()
47 blurFilter.SetNumberOfIterations(5)
48 blurFilter.SetTimeStep(0.125)
49 image = blurFilter.Execute(image)
55 segmentationFilter.SetLower(float(sys.argv[3]))
56 segmentationFilter.SetUpper(float(sys.argv[4]))
57 segmentationFilter.SetReplaceValue(255)
59 for i
in range(5, len(sys.argv) - 1, 2):
60 seed = [int(sys.argv[i]), int(sys.argv[i + 1])]
61 segmentationFilter.AddSeed(seed)
62 print(
"Adding seed at: ", seed,
" with intensity: ", image.GetPixel(*seed))
65 image = segmentationFilter.Execute(image)
72 writer.SetFileName(sys.argv[2])
75 if "SITK_NOSHOW" not in os.environ: