SimpleITK  
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
reader.SetFileName(args[0]);
Image image = reader.Execute();
// Execute Gaussian smoothing filter
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
writer.SetFileName(args[2]);
writer.Execute(destImage);
} catch (Exception ex) {
Console.WriteLine(ex);
}
}
}
}
A hybrid cast image filter to convert images to other types of images.
Self & SetOutputPixelType(PixelIDValueEnum pixelID)
Image Execute(const Image &)
Read an image file and return a SimpleITK Image.
Self & SetFileName(const PathType &fn)
Write out a SimpleITK image to the specified file location.
Self & SetFileName(const PathType &fileName)
Self & Execute(const Image &)
The Image class for SimpleITK.
Definition sitkImage.h:77
PixelIDValueEnum GetPixelID() const
Computes the smoothing of an image by convolution with the Gaussian kernels implemented as IIR filter...