21 import SimpleITK
as sitk
24 if len(sys.argv) < 10:
28 " <inputImage> <outputImage> <seedX> <seedY> <Sigma>",
29 "<SigmoidAlpha> <SigmoidBeta> <TimeThreshold>",
33 inputFilename = sys.argv[1]
34 outputFilename = sys.argv[2]
36 seedPosition = (int(sys.argv[3]), int(sys.argv[4]))
38 sigma = float(sys.argv[5])
39 alpha = float(sys.argv[6])
40 beta = float(sys.argv[7])
41 timeThreshold = float(sys.argv[8])
42 stoppingTime = float(sys.argv[9])
49 smoothing.SetTimeStep(0.125)
50 smoothing.SetNumberOfIterations(5)
51 smoothing.SetConductanceParameter(9.0)
52 smoothingOutput = smoothing.Execute(inputImage)
55 gradientMagnitude.SetSigma(sigma)
56 gradientMagnitudeOutput = gradientMagnitude.Execute(smoothingOutput)
59 sigmoid.SetOutputMinimum(0.0)
60 sigmoid.SetOutputMaximum(1.0)
61 sigmoid.SetAlpha(alpha)
64 sigmoidOutput = sigmoid.Execute(gradientMagnitudeOutput)
69 trialPoint = (seedPosition[0], seedPosition[1], seedValue)
71 fastMarching.AddTrialPoint(trialPoint)
73 fastMarching.SetStoppingValue(stoppingTime)
75 fastMarchingOutput = fastMarching.Execute(sigmoidOutput)
78 thresholder.SetLowerThreshold(0.0)
79 thresholder.SetUpperThreshold(timeThreshold)
80 thresholder.SetOutsideValue(0)
81 thresholder.SetInsideValue(255)
83 result = thresholder.Execute(fastMarchingOutput)