ITK  6.0.0
Insight Toolkit
SphinxExamples/src/Registration/Common/ComputeMeanSquareBetweenTwoImages/Code.cxx
/*=========================================================================
*
* Copyright NumFOCUS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#include "itkImage.h"
int
main(int argc, char * argv[])
{
using ImageType = itk::Image<double, 2>;
if (argc < 3)
{
std::cout << "Usage: " << argv[0] << " imageFile1 imageFile2" << std::endl;
return EXIT_FAILURE;
}
ImageType::Pointer fixedImage = itk::ReadImage<ImageType>(argv[1]);
ImageType::Pointer movingImage = itk::ReadImage<ImageType>(argv[2]);
using TransformType = itk::TranslationTransform<double, 2>;
auto metric = MetricType::New();
auto transform = TransformType::New();
auto interpolator = InterpolatorType::New();
interpolator->SetInputImage(fixedImage);
metric->SetFixedImage(fixedImage);
metric->SetMovingImage(movingImage);
metric->SetFixedImageRegion(fixedImage->GetLargestPossibleRegion());
metric->SetTransform(transform);
metric->SetInterpolator(interpolator);
TransformType::ParametersType params(transform->GetNumberOfParameters());
params.Fill(0.0);
metric->Initialize();
for (double x = -10.0; x <= 10.0; x += 5.0)
{
params(0) = x;
for (double y = -10.0; y <= 10.0; y += 5.0)
{
params(1) = y;
std::cout << params << ": " << metric->GetValue(params) << std::endl;
}
}
return EXIT_SUCCESS;
}
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itkLinearInterpolateImageFunction.h
itkImageFileReader.h
itkImage.h
itkTranslationTransform.h
itkMeanSquaresImageToImageMetric.h
itk::LinearInterpolateImageFunction
Linearly interpolate an image at specified positions.
Definition: itkLinearInterpolateImageFunction.h:51
itk::TranslationTransform
Translation transformation of a vector space (e.g. space coordinates)
Definition: itkTranslationTransform.h:43
itk::MeanSquaresImageToImageMetric
TODO.
Definition: itkMeanSquaresImageToImageMetric.h:41
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:88
New
static Pointer New()