20 """ A SimpleITK example demonstrating the FastMarchingImageFilter class. """
23 import SimpleITK
as sitk
27 """ A SimpleITK example demonstrating the FastMarchingImageFilter class. """
31 "FastMarchingSegmentation",
32 "<inputImage> <outputImage> <seedX> <seedY> <Sigma>",
33 "<SigmoidAlpha> <SigmoidBeta> <TimeThreshold>",
38 inputFilename = args[1]
39 outputFilename = args[2]
41 seedPosition = (int(args[3]), int(args[4]))
43 sigma = float(args[5])
44 alpha = float(args[6])
46 timeThreshold = float(args[8])
47 stoppingTime = float(args[9])
52 smoothing.SetTimeStep(0.125)
53 smoothing.SetNumberOfIterations(5)
54 smoothing.SetConductanceParameter(9.0)
55 smoothingOutput = smoothing.Execute(inputImage)
58 gradientMagnitude.SetSigma(sigma)
59 gradientMagnitudeOutput = gradientMagnitude.Execute(smoothingOutput)
62 sigmoid.SetOutputMinimum(0.0)
63 sigmoid.SetOutputMaximum(1.0)
64 sigmoid.SetAlpha(alpha)
66 sigmoidOutput = sigmoid.Execute(gradientMagnitudeOutput)
71 trialPoint = (seedPosition[0], seedPosition[1], seedValue)
73 fastMarching.AddTrialPoint(trialPoint)
75 fastMarching.SetStoppingValue(stoppingTime)
77 fastMarchingOutput = fastMarching.Execute(sigmoidOutput)
80 thresholder.SetLowerThreshold(0.0)
81 thresholder.SetUpperThreshold(timeThreshold)
82 thresholder.SetOutsideValue(0)
83 thresholder.SetInsideValue(255)
85 result = thresholder.Execute(fastMarchingOutput)
90 "InputImage": inputImage,
91 "SpeedImage": sigmoidOutput,
92 "TimeCrossingMap": fastMarchingOutput,
93 "Segmentation": result,
98 if __name__ ==
"__main__":
99 return_dict = main(sys.argv)