20 from __future__
import print_function
22 import SimpleITK
as sitk
25 if len(sys.argv) < 10:
26 print(
"Usage:", sys.argv[0],
27 " <inputImage> <outputImage> <seedX> <seedY> <Sigma>",
28 "<SigmoidAlpha> <SigmoidBeta> <TimeThreshold>")
31 inputFilename = sys.argv[1]
32 outputFilename = sys.argv[2]
34 seedPosition = (int(sys.argv[3]), int(sys.argv[4]))
36 sigma = float(sys.argv[5])
37 alpha = float(sys.argv[6])
38 beta = float(sys.argv[7])
39 timeThreshold = float(sys.argv[8])
40 stoppingTime = float(sys.argv[9])
47 smoothing.SetTimeStep(0.125)
48 smoothing.SetNumberOfIterations(5)
49 smoothing.SetConductanceParameter(9.0)
50 smoothingOutput = smoothing.Execute(inputImage)
53 gradientMagnitude.SetSigma(sigma)
54 gradientMagnitudeOutput = gradientMagnitude.Execute(smoothingOutput)
57 sigmoid.SetOutputMinimum(0.0)
58 sigmoid.SetOutputMaximum(1.0)
59 sigmoid.SetAlpha(alpha)
62 sigmoidOutput = sigmoid.Execute(gradientMagnitudeOutput)
67 trialPoint = (seedPosition[0], seedPosition[1], seedValue)
69 fastMarching.AddTrialPoint(trialPoint)
71 fastMarching.SetStoppingValue(stoppingTime)
73 fastMarchingOutput = fastMarching.Execute(sigmoidOutput)
76 thresholder.SetLowerThreshold(0.0)
77 thresholder.SetUpperThreshold(timeThreshold)
78 thresholder.SetOutsideValue(0)
79 thresholder.SetInsideValue(255)
81 result = thresholder.Execute(fastMarchingOutput)