1 """=========================================================================
5 ' Licensed under the Apache License, Version 2.0 (the "License");
6 ' you may not use this file except in compliance with the License.
7 ' You may obtain a copy of the License at
9 ' http://www.apache.org/licenses/LICENSE-2.0.txt
11 ' Unless required by applicable law or agreed to in writing, software
12 ' distributed under the License is distributed on an "AS IS" BASIS,
13 ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ' See the License for the specific language governing permissions and
15 ' limitations under the License.
17 '========================================================================="""
22 import SimpleITK
as sitk
31 "inputImage outputImage lowerThreshold",
32 "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)
60 segmentationFilter.SetRadius(radius)
62 for i
in range(5, len(sys.argv) - 1, 2):
63 seed = [int(sys.argv[i]), int(sys.argv[i + 1])]
64 segmentationFilter.AddSeed(seed)
65 print(
"Adding seed at: ", seed,
" with intensity: ", image.GetPixel(*seed))
68 image = segmentationFilter.Execute(image)
74 writer.SetFileName(sys.argv[2])
77 if "SITK_NOSHOW" not in os.environ:
78 sitk.Show(image,
"NeighborhoodConnectedThreshold")