ITK/Examples/VectorImages/VectorResampleImageFilter

From KitwarePublic
< ITK‎ | Examples
Revision as of 12:58, 29 January 2011 by Daviddoria (talk | contribs) (Created page with "The ResampleImageFilter produces concept checking errors if you try to use it with a vector image. The VectorResampleImageFilter must be used instead, as demonstrated in this exa...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

The ResampleImageFilter produces concept checking errors if you try to use it with a vector image. The VectorResampleImageFilter must be used instead, as demonstrated in this example.

VectorResampleImageFilter.cxx

<source lang="cpp">

  1. include "itkImage.h"
  2. include "itkTranslationTransform.h"
  3. include "itkImageFileReader.h"
  4. include "itkVectorResampleImageFilter.h"
  5. include "itkCovariantVector.h"
  6. include "itkNumericTraits.h"

int main(int argc, char *argv[]) {

 typedef itk::CovariantVector<double, 3> VectorType;
 typedef itk::Image<VectorType, 2>  VectorImageType;
 VectorImageType::Pointer image = VectorImageType::New();
 itk::Index<2> start;
 start.Fill(0);
 
 itk::Size<2> size;
 size.Fill(10);
 itk::ImageRegion<2> region(start,size);
 image->SetRegions(region);
 image->Allocate();
 image->FillBuffer(itk::NumericTraits<VectorType>::Zero);
 itk::TranslationTransform<double,2>::Pointer transform =
   itk::TranslationTransform<double,2>::New();
 itk::TranslationTransform<double,2>::OutputVectorType translation;
 translation[0] = 10;
 translation[0] = 20;
 transform->Translate(translation);
 typedef itk::VectorResampleImageFilter< VectorImageType, VectorImageType > VectorResampleFilterType;
 VectorResampleFilterType::Pointer vectorResampleFilter = VectorResampleFilterType::New();
 vectorResampleFilter->SetInput(image);
 vectorResampleFilter->SetTransform(transform);
 vectorResampleFilter->Update();
 return EXIT_SUCCESS;

} </source>

CMakeLists.txt

<source lang="cmake"> cmake_minimum_required(VERSION 2.6)

PROJECT(VectorResampleImageFilter)

FIND_PACKAGE(VTK REQUIRED) INCLUDE(${VTK_USE_FILE})

FIND_PACKAGE(ITK REQUIRED) INCLUDE(${ITK_USE_FILE})

ADD_EXECUTABLE(VectorResampleImageFilter VectorResampleImageFilter.cxx) TARGET_LINK_LIBRARIES(VectorResampleImageFilter vtkHybrid ITKIO ITKNumerics ITKBasicFilters ITKCommon )

</source>