#include <iostream>
#include <stdlib.h>
#include <iomanip>
using sitk::operator<<;
class IterationUpdate
{
public:
: m_Method(m),
m_BSplineTransform(tx)
{}
{
if (m_Method.GetOptimizerIteration() == 0)
{
std::cout << m_BSplineTransform.ToString() << std::endl;
}
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(10) << m_Method.GetMetricValue() << std::endl;
std::cout.copyfmt(state);
}
private:
};
class MultiResolutionIterationUpdate
{
public:
: m_Method(m)
{}
{
if (m_Method.GetCurrentLevel() > 0)
{
std::cout << "Optimizer stop condition: " << m_Method.GetOptimizerStopConditionDescription() << std::endl;
std::cout << " Iteration: " << m_Method.GetOptimizerIteration() << std::endl;
std::cout << " Metric value: " << m_Method.GetMetricValue() << std::endl;
}
std::cout << "--------- Resolution Changing ---------" << std::endl;
}
private:
};
int main(int argc, char *argv[])
{
if ( argc < 4 )
{
std::cerr << "Usage: " << argv[0] << " <fixedImageFilter> <movingImageFile> <outputTransformFile>" << std::endl;
return 1;
}
std::vector<unsigned int> transformDomainMeshSize(fixed.
GetDimension(), 2);
const double learningRate = 5.0;
const unsigned int numberOfIterations = 100u;
const double convergenceMinimumValue = 1
e-4;
const unsigned int convergenceWindowSize = 5;
numberOfIterations,
convergenceMinimumValue,
convergenceWindowSize);
std::vector<unsigned int> scaleFactors = { 1, 2, 5 };
const bool inPlace = true;
inPlace,
scaleFactors);
std::vector<unsigned int> shrinkFactors = { 4, 2, 1 };
std::vector<double> smoothingSigmas = { 4.0, 2.0, 1.0 };
IterationUpdate cmd1(R, tx);
MultiResolutionIterationUpdate cmd2(R);
std::cout << "-------" << std::endl;
std::cout << outTx.
ToString() << std::endl;
return 0;
}