1"""=========================================================================
2 '
3 ' Copyright NumFOCUS
4 '
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
8 '
9 ' http://www.apache.org/licenses/LICENSE-2.0.txt
10 '
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.
16 '
17 '========================================================================="""
18
19import os
20import sys
21
22import SimpleITK as sitk
23
24
25
26
27if len(sys.argv) < 7:
28 print(
29 "Usage:",
30 sys.argv[1],
31 "inputImage outputImage lowerThreshold",
32 "upperThreshold seedX seedY [seed2X seed2Y ... ]",
33 )
34 sys.exit(1)
35
36
37
38
40reader.SetFileName(sys.argv[1])
41image = reader.Execute()
42
43
44
45
47blurFilter.SetNumberOfIterations(5)
48blurFilter.SetTimeStep(0.125)
49image = blurFilter.Execute(image)
50
51
52
53
55segmentationFilter.SetLower(float(sys.argv[3]))
56segmentationFilter.SetUpper(float(sys.argv[4]))
57segmentationFilter.SetReplaceValue(255)
58
59radius = [2, 2]
60segmentationFilter.SetRadius(radius)
61
62for 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))
66
67
68image = segmentationFilter.Execute(image)
69
70
71
72
74writer.SetFileName(sys.argv[2])
75writer.Execute(image)
76
77if "SITK_NOSHOW" not in os.environ:
78 sitk.Show(image,
"NeighborhoodConnectedThreshold")
Denoise an image using curvature driven flow.
Read an image file and return a SimpleITK Image.
Write out a SimpleITK image to the specified file location.
Label pixels that are connected to a seed and lie within a neighborhood.
void SITKIO_EXPORT Show(const Image &image, const std::string &title="", const bool debugOn=ProcessObject::GetGlobalDefaultDebug())