SimpleITK  
SimpleGaussian/SimpleGaussian.cxx
/*=========================================================================
*
* 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.
*
*=========================================================================*/
// This one header will include all SimpleITK filters and external
// objects.
#include <SimpleITK.h>
#include <iostream>
#include <stdlib.h>
// create convenient namespace alias
namespace sitk = itk::simple;
int main ( int argc, char* argv[] ) {
if ( argc < 4 ) {
std::cerr << "Usage: " << argv[0] << " <input> <sigma> <output>\n";
return 1;
}
// Read the image file
reader.SetFileName ( std::string ( argv[1] ) );
sitk::Image image = reader.Execute();
// This filters perform a gaussian blurring with sigma in physical
// space. The output image will be of real type.
gaussian.SetSigma ( atof ( argv[2] ) );
sitk::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.
caster.SetOutputPixelType( image.GetPixelID() );
sitk::Image outputImage = caster.Execute( blurredImage );
// write the image
writer.SetFileName ( std::string ( argv[3] ) );
writer.Execute ( outputImage );
return 0;
}
itk::simple::Image
The Image class for SimpleITK.
Definition: sitkImage.h:76
itk::simple::ImageFileWriter::SetFileName
Self & SetFileName(const std::string &fileName)
itk::simple::SmoothingRecursiveGaussianImageFilter
Computes the smoothing of an image by convolution with the Gaussian kernels implemented as IIR filter...
Definition: sitkSmoothingRecursiveGaussianImageFilter.h:43
itk::simple::ImageFileWriter::Execute
Self & Execute(const Image &)
itk::simple::ImageFileReader
Read an image file and return a SimpleITK Image.
Definition: sitkImageFileReader.h:60
SimpleITK.h
itk::simple::ImageFileReader::SetFileName
Self & SetFileName(const std::string &fn)
itk::simple::Image::GetPixelID
PixelIDValueEnum GetPixelID() const
itk::simple::SmoothingRecursiveGaussianImageFilter::Execute
Image Execute(Image &&image1)
itk::simple::CastImageFilter
A hybrid cast image filter to convert images to other types of images.
Definition: sitkCastImageFilter.h:39
itk::simple::SmoothingRecursiveGaussianImageFilter::SetSigma
Self & SetSigma(std::vector< double > Sigma)
Definition: sitkSmoothingRecursiveGaussianImageFilter.h:61
itk::simple::ImageFileReader::Execute
Image Execute() override
Set/Get The output PixelType of the image.
itk::simple::CastImageFilter::SetOutputPixelType
Self & SetOutputPixelType(PixelIDValueEnum pixelID)
itk::simple
Definition: sitkAdditionalProcedures.h:28
itk::simple::ImageFileWriter
Write out a SimpleITK image to the specified file location.
Definition: sitkImageFileWriter.h:48
itk::simple::CastImageFilter::Execute
Image Execute(const Image &)