#include <iostream>
#include <stdlib.h>
#include <iomanip>
{
public:
: m_Method(m)
{}
void
{
using sitk::operator<<;
if (m_Method.GetOptimizerIteration() == 0)
{
std::cout << "Estimated Scales: " << m_Method.GetOptimizerScales() << 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(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::cout << "Usage: " << argv[0] << " <fixedImageFile> <movingImageFile> <outputTransformFile>" << std::endl;
return 1;
}
1e-4,
500,
0.5,
1e-8);
IterationUpdate cmd(R);
std::cout << "-------" << std::endl;
std::cout << outTx.
ToString() << std::endl;
if (getenv("SITK_NOSHOW") == nullptr)
{
sitk::Show(cimg,
"ImageRegistration3 Composition");
}
return 0;
}
An implementation of the Command design pattern for callback.
An interface method to the modular ITKv4 registration framework.
void SetMetricAsCorrelation()
Use negative normalized cross correlation image metric.
void SetInterpolator(InterpolatorEnum Interpolator)
Set and get the interpolator to use.
Transform Execute(const Image &fixed, const Image &moving)
Optimize the configured registration problem.
std::string GetOptimizerStopConditionDescription() const
void SetOptimizerAsRegularStepGradientDescent(double learningRate, double minStep, unsigned int numberOfIterations, double relaxationFactor=0.5, double gradientMagnitudeTolerance=1e-4, EstimateLearningRateType estimateLearningRate=Never, double maximumStepSizeInPhysicalUnits=0.0)
Regular Step Gradient descent optimizer.
void SetOptimizerScalesFromIndexShift(unsigned int centralRegionRadius=5, double smallParameterVariation=0.01)
Estimate scales from maximum voxel shift in index space cause by parameter change.
unsigned int GetOptimizerIteration() const
double GetMetricValue() const
void SetInitialTransform(const Transform &transform)
Set the initial transform and parameters to optimize.
The Image class for SimpleITK.
virtual int AddCommand(itk::simple::EventEnum event, itk::simple::Command &cmd)
Add a Command Object to observer the event.
Resample an image via a coordinate transform.
Image Execute(const Image &image1)
void SetInterpolator(InterpolatorEnum Interpolator)
void SetTransform(Transform Transform)
void SetReferenceImage(const Image &refImage)
void SetDefaultPixelValue(double DefaultPixelValue)
SITKIO_EXPORT Image ReadImage(const PathType &filename, PixelIDValueEnum outputPixelType=sitkUnknown, const std::string &imageIO="")
ReadImage is a procedural interface to the ImageFileReader class which is convenient for most image r...
Image Compose(const std::vector< Image > &images)
ComposeImageFilter combine several scalar images into a multicomponent image.
@ sitkLinear
N-D linear interpolation.
void SITKIO_EXPORT Show(const Image &image, const std::string &title="", const bool debugOn=ProcessObject::GetGlobalDefaultDebug())
@ sitkIterationEvent
Occurs with some algorithms that run for a fixed or undetermined number of iterations.
Transform CenteredTransformInitializer(const Image &fixedImage, const Image &movingImage, const Transform &transform, CenteredTransformInitializerFilter::OperationModeType operationMode=itk::simple::CenteredTransformInitializerFilter::MOMENTS)
CenteredTransformInitializer is a helper class intended to initialize the center of rotation and the ...
Image Add(Image &&image1, const Image &image2)
Pixel-wise addition of two images.
Image Divide(Image &&image1, const Image &image2)
Pixel-wise division of two images.
SITKCommon_EXPORT void WriteTransform(const Transform &transform, const PathType &filename)
Image RescaleIntensity(Image &&image1, double outputMinimum=0, double outputMaximum=255)
Applies a linear transformation to the intensity levels of the input Image .
Image Cast(const Image &image, PixelIDValueEnum pixelID)