using System;
namespace itk.simple.examples
{
public class DemonsRegistration2
{
public class IterationUpdate :
Command
{
{
this.filter = filter;
}
public override void Execute()
{
}
}
public static void Main(string[] args)
{
if (args.Length < 3)
{
Console.WriteLine("Usage: DemonsRegistration2 <fixedImageFile> <movingImageFile> [initialTransformFile] <outputTransformFile>");
return;
}
var fixedImage = SimpleITK.ReadImage(args[0]);
var movingImage = SimpleITK.ReadImage(args[1]);
matcher.SetNumberOfHistogramLevels(128);
else
matcher.SetNumberOfHistogramLevels(1024);
matcher.SetNumberOfMatchPoints(7);
matcher.ThresholdAtMeanIntensityOn();
movingImage = matcher.Execute(movingImage, fixedImage);
demons.SetNumberOfIterations(200);
demons.SetStandardDeviations(1.0);
var cmd = new IterationUpdate(demons);
demons.AddCommand(
EventEnum.sitkIterationEvent, cmd);
if (args.Length > 3)
{
var initialTransform = SimpleITK.ReadTransform(args[2]);
var outputTransformFile = args[3];
toDisplacementFilter.SetReferenceImage(fixedImage);
displacementField = toDisplacementFilter.Execute(initialTransform);
displacementField = demons.Execute(fixedImage, movingImage, displacementField);
SimpleITK.WriteTransform(outTx, outputTransformFile);
}
else
{
displacementField = demons.Execute(fixedImage, movingImage);
SimpleITK.WriteTransform(outTx, args[2]);
}
Console.WriteLine("-------");
Console.WriteLine(string.Format("Number Of Iterations: {0}", demons.GetElapsedIterations()));
Console.WriteLine(string.Format(" RMS: {0}", demons.GetRMSChange()));
if (Environment.GetEnvironmentVariable("SITK_NOSHOW") == null)
{
resampler.SetReferenceImage(fixedImage);
resampler.SetDefaultPixelValue(100);
var outImg = resampler.Execute(movingImage);
var simg1 = SimpleITK.Cast(SimpleITK.RescaleIntensity(fixedImage),
PixelIDValueEnum.sitkUInt8);
var simg2 = SimpleITK.Cast(SimpleITK.RescaleIntensity(outImg),
PixelIDValueEnum.sitkUInt8);
var cimg = SimpleITK.Compose(simg1, simg2, SimpleITK.Add(SimpleITK.Divide(simg1, 2.0), SimpleITK.Divide(simg2, 2.0)));
SimpleITK.Show(cimg, "DeformableRegistration2 Composition");
}
}
}
}
An implementation of the Command design pattern for callback.
Deformably register two images using a symmetric forces demons algorithm.
uint32_t GetElapsedIterations() const
Number of iterations run.
Normalize the grayscale values for a source image by matching the shape of the source image histogram...
The Image class for SimpleITK.
Resample an image via a coordinate transform.
EventEnum
Events which can be observed from ProcessObject.
PixelIDValueEnum
Enumerated values of pixelIDs.