#include <iostream>
int main(
int argc,
char** argv)
{
if (argc < 11)
{
std::cerr << "Usage: " << argv[0];
std::cerr <<
" fixedFileName movingFileName fieldOutNameHorizontal fieldOutNameVertical fieldMetric warped ";
std::cerr << "smoothingSigma metricRadius explorationRadius subpixelPrecision";
return EXIT_FAILURE;
}
const unsigned int ImageDimension = 2;
typedef double PixelType;
typedef double CoordinateRepresentationType;
typedef unsigned char OutputPixelType;
ImageDimension> DeformationFieldType;
InputReaderType::Pointer fReader = InputReaderType::New();
fReader->SetFileName(argv[1]);
InputReaderType::Pointer mReader = InputReaderType::New();
mReader->SetFileName(argv[2]);
InputImageType> InputBlurType;
InputBlurType::Pointer fBlur = InputBlurType::New();
fBlur->SetInput(fReader->GetOutput());
fBlur->SetSigma(atof(argv[7]));
InputBlurType::Pointer mBlur = InputBlurType::New();
mBlur->SetInput(mReader->GetOutput());
mBlur->SetSigma(atof(argv[7]));
MetricImageType,
DeformationFieldType>
RegistrationFilterType;
RegistrationFilterType::Pointer registrator = RegistrationFilterType::New();
registrator->SetMovingInput(mBlur->GetOutput());
registrator->SetFixedInput(fBlur->GetOutput());
typedef RegistrationFilterType::SizeType RadiusType;
RadiusType searchRadius;
searchRadius[0] = atoi(argv[8]);
searchRadius[1] = atoi(argv[8]);
registrator->SetSearchRadius(searchRadius);
std::cout << "Exploration radius " << registrator->GetSearchRadius() << std::endl;
RadiusType metricRadius;
metricRadius[0] = atoi(argv[9]);
metricRadius[1] = atoi(argv[9]);
registrator->SetRadius(metricRadius);
std::cout << "Metric radius " << registrator->GetRadius() << std::endl;
registrator->SetSubPixelAccuracy(atof(argv[10]));
if(argc > 11)
{
<InputImageType, InputImageType> MRSDMetricType;
MRSDMetricType::Pointer mrsdMetric = MRSDMetricType::New();
registrator->SetMetric(mrsdMetric);
registrator->MinimizeOff();
}
InputImageType>
ChannelExtractionFilterType;
ChannelExtractionFilterType::Pointer channelExtractor =
ChannelExtractionFilterType::New();
channelExtractor->SetInput(registrator->GetOutputDeformationField());
channelExtractor->SetChannel(1);
OutputImageType> RescalerType;
RescalerType::Pointer fieldRescaler = RescalerType::New();
fieldRescaler->SetInput(channelExtractor->GetOutput());
fieldRescaler->SetOutputMaximum(255);
fieldRescaler->SetOutputMinimum(0);
DFWriterType::Pointer dfWriter = DFWriterType::New();
dfWriter->SetFileName(argv[3]);
dfWriter->SetInput(fieldRescaler->GetOutput());
dfWriter->Update();
channelExtractor->SetChannel(2);
dfWriter->SetFileName(argv[4]);
dfWriter->Update();
DeformationFieldType> WarperType;
WarperType::Pointer warper = WarperType::New();
InputImageType::PixelType padValue = 4.0;
warper->SetInput(mReader->GetOutput());
warper->SetDeformationField(registrator->GetOutputDeformationField());
warper->SetEdgePaddingValue(padValue);
OutputImageType> MetricRescalerType;
MetricRescalerType::Pointer metricRescaler = MetricRescalerType::New();
metricRescaler->SetInput(registrator->GetOutput());
metricRescaler->SetOutputMinimum(0);
metricRescaler->SetOutputMaximum(255);
WriterType::Pointer writer1 = WriterType::New();
writer1->SetInput(metricRescaler->GetOutput());
writer1->SetFileName(argv[5]);
writer1->Update();
CastFilterType::Pointer caster = CastFilterType::New();
caster->SetInput(warper->GetOutput());
WriterType::Pointer writer2 = WriterType::New();
writer2->SetFileName(argv[6]);
writer2->SetInput(caster->GetOutput());
writer2->Update();
return EXIT_SUCCESS;
}