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

Method Main

Examples/SimpleGaussian/SimpleGaussian.cs:23–54  ·  view source on GitHub ↗
(string[] args)

Source from the content-addressed store, hash-verified

21namespace itk.simple.examples {
22 class SimpleGaussian {
23 static void Main(string[] args) {
24 try {
25 if (args.Length < 3) {
26 Console.WriteLine("Usage: SimpleGaussian <input> <sigma> <output>");
27 return;
28 }
29 // Read input image
30 ImageFileReader reader = new ImageFileReader();
31 reader.SetFileName(args[0]);
32 Image image = reader.Execute();
33
34 // Execute Gaussian smoothing filter
35 SmoothingRecursiveGaussianImageFilter gaussian = new SmoothingRecursiveGaussianImageFilter();
36 gaussian.SetSigma(Double.Parse(args[1]));
37 Image blurredImage = gaussian.Execute(image);
38
39 // Covert the real output image back to the original pixel type , to
40 // make writing easier , as many file formats don 't support real
41 // pixels .
42 CastImageFilter castFilter = new CastImageFilter();
43 castFilter.SetOutputPixelType(image.GetPixelID());
44 Image destImage = castFilter.Execute(blurredImage);
45
46 // Write output image
47 ImageFileWriter writer = new ImageFileWriter();
48 writer.SetFileName(args[2]);
49 writer.Execute(destImage);
50
51 } catch (Exception ex) {
52 Console.WriteLine(ex);
53 }
54 }
55 }
56}

Callers

nothing calls this directly

Calls 4

SetFileNameMethod · 0.45
ExecuteMethod · 0.45
SetOutputPixelTypeMethod · 0.45
GetPixelIDMethod · 0.45

Tested by

no test coverage detected