#include <iostream>
#include <stdlib.h>
#include <iomanip>
#include <numeric>
class IterationUpdate
{
public:
: m_Method(m)
{}
{
using sitk::operator<<;
std::ios state(NULL);
state.copyfmt(std::cout);
std::cout << std::fixed << std::setfill(' ') << std::setprecision( 5 );
std::cout << std::setw(3) << m_Method.GetOptimizerIteration();
std::cout << " = " << std::setw(7) << m_Method.GetMetricValue();
std::cout << " : " << m_Method.GetOptimizerPosition() << std::endl;
std::cout.copyfmt(state);
}
private:
};
int main(int argc, char *argv[])
{
if ( argc < 4 )
{
std::cerr << "Usage: " << argv[0] << " <fixedImageFilter> <movingImageFile> <outputTransformFile>" << std::endl;
return 1;
}
const double learningRate = 1;
const unsigned int numberOfIterations = 200;
const double convergenceMinimumValue = 1
e-4;
const unsigned int convergenceWindowSize=5;
numberOfIterations,
convergenceMinimumValue,
convergenceWindowSize);
IterationUpdate cmd(R);
std::cout << "-------" << std::endl;
std::cout << outTx.
ToString() << std::endl;
return 0;
}
The Image class for SimpleITK.
virtual int AddCommand(itk::simple::EventEnum event, itk::simple::Command &cmd)
Add a Command Object to observer the event.
@ sitkLinear
N-D linear interpolation.
std::string GetOptimizerStopConditionDescription() const
SITKCommon_EXPORT void WriteTransform(const Transform &transform, const std::string &filename)
Image Normalize(const Image &image1)
Normalize an image by setting its mean to zero and variance to one.
An implementation of the Command design pattern for callback.
double GetMetricValue() const
unsigned int GetDimension() const
Image DiscreteGaussian(const Image &image1, double variance, unsigned int maximumKernelWidth=32u, double maximumError=0.01, bool useImageSpacing=true)
Blurs an image by separable convolution with discrete gaussian kernels. This filter performs Gaussian...
@ sitkFloat32
32 bit float
SITKIO_EXPORT Image ReadImage(const std::string &filename, PixelIDValueEnum outputPixelType=sitkUnknown, const std::string &imageIO="")
ReadImage is a procedural interface to the ImageFileReader class which is convenient for most image r...
An interface method to the modular ITKv4 registration framework.
Self & SetOptimizerAsGradientDescentLineSearch(double learningRate, unsigned int numberOfIterations, double convergenceMinimumValue=1e-6, unsigned int convergenceWindowSize=10, double lineSearchLowerLimit=0, double lineSearchUpperLimit=5.0, double lineSearchEpsilon=0.01, unsigned int lineSearchMaximumIterations=20, EstimateLearningRateType estimateLearningRate=Once, double maximumStepSizeInPhysicalUnits=0.0)
Gradient descent optimizer with a golden section line search.
Self & SetInitialTransform(const Transform &transform)
Set the initial transform and parameters to optimize.
Transform Execute(const Image &fixed, const Image &moving)
Optimize the configured registration problem.
@ sitkIterationEvent
Occurs with some algorithms that run for a fixed or undetermined number of iterations.
Self & SetInterpolator(InterpolatorEnum Interpolator)
Set and get the interpolator to use.
Self & SetMetricAsJointHistogramMutualInformation(unsigned int numberOfHistogramBins=20, double varianceForJointPDFSmoothing=1.5)
Use mutual information between two images.
unsigned int GetOptimizerIteration() const