|
|
Line 1: |
Line 1: |
| 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. | | {{warning|1=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. |
| | | }} |
| ==VectorResampleImageFilter.cxx==
| |
| <source lang="cpp">
| |
| #include "itkImage.h"
| |
| #include "itkTranslationTransform.h"
| |
| #include "itkImageFileReader.h"
| |
| #include "itkVectorResampleImageFilter.h"
| |
| #include "itkCovariantVector.h"
| |
| #include "itkNumericTraits.h"
| |
| | |
| int main(int, char *[])
| |
| {
| |
| 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[1] = 20;
| |
| transform->Translate(translation);
| |
| | |
| typedef itk::VectorResampleImageFilter< VectorImageType, VectorImageType > VectorResampleFilterType;
| |
| VectorResampleFilterType::Pointer vectorResampleFilter = VectorResampleFilterType::New();
| |
| vectorResampleFilter->SetInput(image);
| |
| vectorResampleFilter->SetSize(image->GetLargestPossibleRegion().GetSize());
| |
| vectorResampleFilter->SetTransform(transform);
| |
| vectorResampleFilter->Update();
| |
| | |
| return EXIT_SUCCESS;
| |
| }
| |
| </source>
| |
| | |
| {{ITKCMakeLists|{{SUBPAGENAME}}}}
| |