using System;
namespace itk.simple.examples
{
{
{
m_Method = m;
}
public override void Execute()
{
{
Console.WriteLine(String.Format(
"\tLevel: {0,3}", m_Method.
GetCurrentLevel()));
Console.Write(String.Format("\tScales: [{0:F5}", scales[0]));
for (int i = 1; i < scales.Count; i++)
{
Console.Write(String.Format(", {0:F5}", scales[i]));
}
Console.WriteLine("]");
}
Console.WriteLine(String.Format(
"\tMetric Value: {0:F5}", m_Method.
GetMetricValue()));
{
}
}
}
class MultiResolutionIterationUpdate :
Command
{
{
m_Method = m;
}
public override void Execute()
{
Console.WriteLine("============= Resolution Change =============");
}
}
class ImageRegistrationMethodDisplacement1
{
static void Main(string[] args)
{
if (args.Length < 3)
{
Console.WriteLine("Usage: {0} <fixedImageFile> <movingImageFile> <outputTransformFile>",
System.AppDomain.CurrentDomain.FriendlyName);
return;
}
Transform initialTx = SimpleITK.CenteredTransformInitializer(fixedImage, movingImage,
VectorUInt32 shrinkFactors = new VectorUInt32();
shrinkFactors.Add(3); shrinkFactors.Add(2); shrinkFactors.Add(1);
VectorDouble smoothingSigmas = new VectorDouble();
smoothingSigmas.Add(2.0); smoothingSigmas.Add(1.0); smoothingSigmas.Add(1.0);
double learningRate = 1.0;
uint numberOfIterations = 100;
double convergenceMinimumValue = 1e-6;
uint convergenceWindowSize = 10;
convergenceMinimumValue, convergenceWindowSize, estimateLearningRate);
IterationUpdate cmd = new IterationUpdate(R);
MultiResolutionIterationUpdate cmd2 = new MultiResolutionIterationUpdate(R);
Console.WriteLine("-------");
Console.WriteLine(String.Format(
" Metric value: {0}", R.
GetMetricValue()));
double varianceForUpdateField = 0.0;
double varianceForTotalField = 1.5;
shrinkFactors = new VectorUInt32();
shrinkFactors.Add(3); shrinkFactors.Add(2); shrinkFactors.Add(1);
smoothingSigmas = new VectorDouble();
smoothingSigmas.Add(2.0); smoothingSigmas.Add(1.0); smoothingSigmas.Add(1.0);
learningRate = 1.0;
numberOfIterations = 300;
convergenceMinimumValue = 1e-6;
convergenceWindowSize = 10;
convergenceMinimumValue, convergenceWindowSize, estimateLearningRate);
R.
Execute(fixedImage, movingImage);
Console.WriteLine("-------");
Console.WriteLine(displacementTx.
ToString());
Console.WriteLine(String.Format(
" Metric value: {0}", R.
GetMetricValue()));
VectorOfTransform transforms = new VectorOfTransform();
transforms.Add(outTx1);
transforms.Add(displacementTx);
SimpleITK.WriteTransform(outTx, args[2]);
}
}
}
An implementation of the Command design pattern for callback.
An interface method to the modular ITKv4 registration framework.
void SetInterpolator(InterpolatorEnum Interpolator)
Set and get the interpolator to use.
std::vector< double > GetOptimizerScales() const
Get the OptimizerScales.
Transform Execute(const Image &fixed, const Image &moving)
Optimize the configured registration problem.
void SetMetricAsJointHistogramMutualInformation(unsigned int numberOfHistogramBins=20, double varianceForJointPDFSmoothing=1.5)
Use mutual information between two images.
void MetricUseFixedImageGradientFilterOff()
Enable image gradient computation by a filter.
void SetShrinkFactorsPerLevel(const std::vector< unsigned int > &shrinkFactors)
Set the isotropic shrink factors for each level.
std::string GetOptimizerStopConditionDescription() const
void SetOptimizerAsGradientDescent(double learningRate, unsigned int numberOfIterations, double convergenceMinimumValue=1e-6, unsigned int convergenceWindowSize=10, EstimateLearningRateType estimateLearningRate=Once, double maximumStepSizeInPhysicalUnits=0.0)
Gradient descent optimizer.
double GetOptimizerConvergenceValue() const
void SetSmoothingSigmasPerLevel(const std::vector< double > &smoothingSigmas)
Set the sigmas of Gaussian used for smoothing.
unsigned int GetCurrentLevel() const
void SetOptimizerScalesFromPhysicalShift(unsigned int centralRegionRadius=5, double smallParameterVariation=0.01)
Estimating scales of transform parameters a step sizes, from the maximum voxel shift in physical spac...
double GetOptimizerLearningRate() const
unsigned int GetOptimizerIteration() const
void SetMovingInitialTransform(const Transform &transform)
Set a fixed transform component towards moving domain.
double GetMetricValue() const
void SetInitialTransform(const Transform &transform)
Set the initial transform and parameters to optimize.
void SetMetricAsANTSNeighborhoodCorrelation(unsigned int radius)
Use normalized cross correlation using a small neighborhood for each voxel between two images,...
The Image class for SimpleITK.
unsigned int GetDimension() const
std::vector< unsigned int > GetSize() const
void CopyInformation(const Image &srcImage)
Copy common meta-data from an image to this one.
virtual int AddCommand(itk::simple::EventEnum event, itk::simple::Command &cmd)
Add a Command Object to observer the event.
EventEnum
Events which can be observed from ProcessObject.
PixelIDValueEnum
Enumerated values of pixelIDs.