SimpleITK  2.0.0rc1.post255
SimpleGaussian/SimpleGaussian.cs
/*=========================================================================
*
* Copyright NumFOCUS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
using System;
using itk.simple;
namespace itk.simple.examples {
class SimpleGaussian {
static void Main(string[] args) {
try {
if (args.Length < 3) {
Console.WriteLine("Usage: SimpleGaussian <input> <sigma> <output>");
return;
}
// Read input image
ImageFileReader reader = new ImageFileReader();
reader.SetFileName(args[0]);
Image image = reader.Execute();
// Execute Gaussian smoothing filter
SmoothingRecursiveGaussianImageFilter gaussian = new SmoothingRecursiveGaussianImageFilter();
gaussian.SetSigma(Double.Parse(args[1]));
Image blurredImage = gaussian.Execute(image);
// Covert the real output image back to the original pixel type , to
// make writing easier , as many file formats don 't support real
// pixels .
CastImageFilter castFilter = new CastImageFilter();
castFilter.SetOutputPixelType(image.GetPixelID());
Image destImage = castFilter.Execute(blurredImage);
// Write output image
ImageFileWriter writer = new ImageFileWriter();
writer.SetFileName(args[2]);
writer.Execute(destImage);
} catch (Exception ex) {
Console.WriteLine(ex);
}
}
}
}
itk
itk::simple
Definition: sitkAdditionalProcedures.h:29