MCPcopy Create free account
hub / github.com/SimpleITK/SimpleITK / Main

Method Main

Examples/CSharp/CannySegmentationLevelSetImageFilter.cs:29–124  ·  view source on GitHub ↗
(string[] args)

Source from the content-addressed store, hash-verified

27 public class Program
28 {
29 static void Main(string[] args)
30 {
31 if (args.Length < 8)
32 {
33 Console.WriteLine("Missing Parameters ");
34 Console.WriteLine("Usage: " + System.AppDomain.CurrentDomain.FriendlyName +
35 "inputImage initialModel outputImage cannyThreshold " +
36 "cannyVariance advectionWeight initialModelIsovalue maximumIterations ");
37 return;
38 }
39
40 string inputFilename = args[0];
41 string initialModelFilename = args[1];
42
43 string outputFilename = args[2];
44
45 double cannyThreshold = double.Parse(args[3], CultureInfo.InvariantCulture);
46 double cannyVariance = double.Parse(args[4], CultureInfo.InvariantCulture);
47 double advectionWeight = double.Parse(args[5], CultureInfo.InvariantCulture);
48 double intialModelIsovalue = double.Parse(args[6], CultureInfo.InvariantCulture);
49 uint maxIterations = uint.Parse(args[7], CultureInfo.InvariantCulture);
50
51 // Read input image
52
53 SitkImage inputImage = SimpleITK.ReadImage(inputFilename, PixelId.sitkFloat32);
54 SitkImage initialModel = SimpleITK.ReadImage(initialModelFilename, PixelId.sitkFloat32);
55
56 // The input image will be processed with a few iterations of
57 // feature-preserving diffusion. We create a filter and set the
58 // appropriate parameters.
59
60 GradientAnisotropicDiffusionImageFilter diffusion=new GradientAnisotropicDiffusionImageFilter();
61 diffusion.SetConductanceParameter(1.0);
62 diffusion.SetTimeStep(0.125);
63 diffusion.SetNumberOfIterations(5);
64 SitkImage diffusedImage=diffusion.Execute(inputImage);
65
66 // As with the other ITK level set segmentation filters, the terms of the
67 // CannySegmentationLevelSetImageFilter level set equation can be
68 // weighted by scalars. For this application we will modify the relative
69 // weight of the advection term. The propagation and curvature term weights
70 // are set to their defaults of 0 and 1, respectively.
71
72 CannySegmentationLevelSetImageFilter cannySegmentation = new CannySegmentationLevelSetImageFilter();
73 cannySegmentation.SetAdvectionScaling(advectionWeight);
74 cannySegmentation.SetCurvatureScaling(1.0);
75 cannySegmentation.SetPropagationScaling(0.0);
76
77 // The maximum number of iterations is specified from the command line.
78 // It may not be desirable in some applications to run the filter to
79 // convergence. Only a few iterations may be required.
80
81 cannySegmentation.SetMaximumRMSError(0.01);
82 cannySegmentation.SetNumberOfIterations(maxIterations);
83
84 // There are two important parameters in the
85 // CannySegmentationLevelSetImageFilter to control the behavior of the
86 // Canny edge detection. The variance parameter controls the

Callers

nothing calls this directly

Calls 1

ExecuteMethod · 0.45

Tested by

no test coverage detected