ITK/Examples/Broken/ImageProcessing/MutualInformationImageToImageFilter: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
(Created page with "==MutualInformationImageToImageFilter.cxx== <source lang="cpp"> #include "itkMutualInformationImageToImageMetric.h" #include "itkRandomImageSource.h" #include "itkTranslationTran...")
 
(Deprecated content that is moved to sphinx)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==MutualInformationImageToImageFilter.cxx==
{{warning|1=The media wiki content on this page is no longer maintainedThe examples presented on the https://itk.org/Wiki/* pages likely require ITK version 4.13 or earlier releasesIn many cases, the examples on this page no longer conform to the best practices for modern ITK versions.
<source lang="cpp">
}}
#include "itkMutualInformationImageToImageMetric.h"
#include "itkRandomImageSource.h"
#include "itkTranslationTransform.h"
 
//typedef itk::Image< unsigned char, 2>  ImageType;
typedef itk::Image< float, 2> ImageType;
 
int main( int argc, char *argv[] )
{
  itk::Size<2> size;
  size.Fill(10);
   
  itk::RandomImageSource<ImageType>::Pointer randomImageSource1 = itk::RandomImageSource<ImageType>::New();
  randomImageSource1->SetNumberOfThreads(1); // to produce non-random results
  randomImageSource1->SetSize(size);
  randomImageSource1->Update();
 
  ImageType::Pointer fixedImage = randomImageSource1->GetOutput();
 
  itk::RandomImageSource<ImageType>::Pointer randomImageSource2 = itk::RandomImageSource<ImageType>::New();
  randomImageSource2->SetNumberOfThreads(1); // to produce non-random results
  randomImageSource2->SetSize(size);
  randomImageSource2->Update();
 
  ImageType::Pointer movingImage = randomImageSource2->GetOutput();
 
  typedef itk::TranslationTransform<double, 2> TranslationTransformType; // This cannot be float for some reason?
  TranslationTransformType::Pointer transform = TranslationTransformType::New();
 
  typedef itk::MutualInformationImageToImageMetric<ImageType, ImageType >    MetricType;
 
  MetricType::Pointer metric = MetricType::New();
 
  metric->SetTransform(transform);
 
  metric->SetFixedImageStandardDeviation( 0.4 );
  metric->SetMovingImageStandardDeviation( 0.4 );
 
  metric->SetFixedImage(fixedImage);
  metric->SetMovingImage(movingImage);
 
  //MetricType::ParametersType parameters;
  TranslationTransformType::ParametersType parameters;
  parameters.SetSize(2);
   parameters.Fill(0);
  std::cout << "parameters: " << parameters << std::endl;
 
  MetricType::MeasureType value = metric->GetValue(parameters);
 
  std::cout << "Value: " << value << std::endl;
 
  return EXIT_SUCCESS;
}
 
 
</source>
 
{{ITKCMakeLists|MutualInformationImageToImageFilter}}

Latest revision as of 22:19, 4 June 2019

Warning: The media wiki content on this page is no longer maintained. The examples presented on the https://itk.org/Wiki/* pages likely require ITK version 4.13 or earlier releases. In many cases, the examples on this page no longer conform to the best practices for modern ITK versions.