#include "itkConfigure.h"
#ifndef ITK_USE_FFTWD
# error "This program needs FFTWD to work."
#endif
{
public:
using Self = CommandIterationUpdate;
itkNewMacro(CommandIterationUpdate);
protected:
CommandIterationUpdate() = default;
InternalImageType,
InternalImageType,
DisplacementFieldType,
InternalImageType,
InternalImageType,
DisplacementFieldType>>;
public:
void
{
}
void
{
const auto * filter = static_cast<const RegistrationFilterType *>(object);
if (!(itk::IterationEvent().CheckEvent(&event)))
{
return;
}
std::cout << filter->GetMetric() << std::endl;
}
};
int
main(int argc, char * argv[])
{
if (argc < 4)
{
std::cerr << "Missing Parameters " << std::endl;
std::cerr << "Usage: " << argv[0];
std::cerr << " fixedImageFile movingImageFile ";
std::cerr << " outputImageFile " << std::endl;
return EXIT_FAILURE;
}
using PixelType = short;
fixedImageReader->SetFileName(argv[1]);
movingImageReader->SetFileName(argv[2]);
using InternalPixelType = float;
using FixedImageCasterType =
using MovingImageCasterType =
fixedImageCaster->SetInput(fixedImageReader->GetOutput());
movingImageCaster->SetInput(movingImageReader->GetOutput());
using MatchingFilterType =
matcher->SetInput(movingImageCaster->GetOutput());
matcher->SetReferenceImage(fixedImageCaster->GetOutput());
matcher->SetNumberOfHistogramLevels(1024);
matcher->SetNumberOfMatchPoints(7);
matcher->ThresholdAtMeanIntensityOn();
InternalImageType,
InternalImageType,
DisplacementFieldType,
InternalImageType,
InternalImageType,
DisplacementFieldType>>;
filter->SetTimeStep(1);
filter->SetConstraintWeight(0.1);
filter->AddObserver(itk::IterationEvent(), observer);
using MultiResRegistrationFilterType =
InternalImageType,
DisplacementFieldType>;
multires->SetRegistrationFilter(filter);
multires->SetNumberOfLevels(3);
multires->SetFixedImage(fixedImageCaster->GetOutput());
multires->SetMovingImage(matcher->GetOutput());
unsigned int nIterations[4] = { 10, 20, 50, 50 };
multires->SetNumberOfIterations(nIterations);
multires->Update();
using DisplacementFieldTransformType =
displacementTransform->SetDisplacementField(multires->GetOutput());
MovingImageType,
InternalPixelType,
InternalPixelType>;
using InterpolatorType =
warper->SetInput(movingImageReader->GetOutput());
warper->SetInterpolator(interpolator);
warper->SetOutputSpacing(fixedImage->GetSpacing());
warper->SetOutputOrigin(fixedImage->GetOrigin());
warper->SetOutputDirection(fixedImage->GetDirection());
warper->SetTransform(displacementTransform);
using OutputPixelType = unsigned short;
using CastFilterType =
writer->SetFileName(argv[3]);
caster->SetInput(warper->GetOutput());
writer->SetInput(caster->GetOutput());
writer->Update();
if (argc > 4)
{
fieldWriter->SetFileName(argv[4]);
fieldWriter->SetInput(multires->GetOutput());
try
{
fieldWriter->Update();
}
catch (
const itk::ExceptionObject &
e)
{
}
}
return EXIT_SUCCESS;
}