SimpleITK  
Elastix/elx.cxx
// This one header will include all SimpleITK filters and external
// objects.
#include <SimpleITK.h>
#include <iostream>
#include <stdlib.h>
namespace sitk = itk::simple;
int
main(int argc, char * argv[])
{
if (argc < 5)
{
std::cerr << "Usage: " << argv[0]
<< " <fixedImage> <movingImage> <parameterFile> <outputImage> <outputParameterFile> \n";
return 1;
}
// Instantiate SimpleElastix
sitk::ElastixImageFilter elastixImageFilter;
// Read input
reader.SetFileName(std::string(argv[1]));
elastixImageFilter.SetFixedImage(reader.Execute());
reader.SetFileName(std::string(argv[2]));
elastixImageFilter.SetMovingImage(reader.Execute());
elastixImageFilter.SetParameterMap(sitk::ReadParameterFile(std::string(argv[3])));
elastixImageFilter.LogToConsoleOn();
// Run registration
elastixImageFilter.Execute();
// Write result image
writer.SetFileName(std::string(argv[4]));
writer.Execute(elastixImageFilter.GetResultImage());
// Write parameter file. This test executable only supports one parameter map and one transform parameter map.
sitk::WriteParameterFile(elastixImageFilter.GetTransformParameterMap()[0], std::string(argv[5]));
return 0;
}
itk::simple::ElastixImageFilter::GetResultImage
Image GetResultImage()
Returns the result image.
itk::simple::WriteParameterFile
SITKElastix_EXPORT void WriteParameterFile(const std::map< std::string, std::vector< std::string >> parameterMap, const std::string filename)
itk::simple::ImageFileWriter::Execute
Self & Execute(const Image &)
itk::simple::ImageFileReader
Read an image file and return a SimpleITK Image.
Definition: sitkImageFileReader.h:74
SimpleITK.h
itk::simple::ElastixImageFilter
The class that wraps the elastix registration library.
Definition: sitkElastixImageFilter.h:36
itk::simple::ElastixImageFilter::SetMovingImage
Self & SetMovingImage(const Image &movingImages)
Sets a moving image. Stores the image into the container of moving images.
itk::simple::ImageFileReader::SetFileName
Self & SetFileName(const PathType &fn)
itk::simple::ElastixImageFilter::Execute
Image Execute()
Executes the registration, and returns the result image.
itk::simple::ElastixImageFilter::GetTransformParameterMap
std::vector< std::map< std::string, std::vector< std::string > > > GetTransformParameterMap()
Returns all transform parameter maps.
itk::simple::ImageFileReader::Execute
Image Execute() override
Set/Get The output PixelType of the image.
itk::simple::ImageFileWriter::SetFileName
Self & SetFileName(const PathType &fileName)
itk::simple::ElastixImageFilter::SetFixedImage
Self & SetFixedImage(const Image &fixedImage)
Sets a fixed image. Stores the image into the container of fixed images.
itk::simple::ElastixImageFilter::LogToConsoleOn
Self & LogToConsoleOn()
Switches logging to console on.
itk::simple::ElastixImageFilter::SetParameterMap
Self & SetParameterMap(const std::string transformName, const unsigned int numberOfResolutions=4u, const double finalGridSpacingInPhysicalUnits=10.0)
Specifies the parameter map by a transformName ("translation", "rigid" , "affine",...
itk::simple
Definition: sitkAdditionalProcedures.h:28
itk::simple::ReadParameterFile
SITKElastix_EXPORT std::map< std::string, std::vector< std::string > > ReadParameterFile(const std::string filename)
itk::simple::ImageFileWriter
Write out a SimpleITK image to the specified file location.
Definition: sitkImageFileWriter.h:51