ITK/Examples/VectorImages/VectorResampleImageFilter
From KitwarePublic
< ITK | Examples
Jump to navigationJump to search
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...")
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">
- include "itkImage.h"
- include "itkTranslationTransform.h"
- include "itkImageFileReader.h"
- include "itkVectorResampleImageFilter.h"
- include "itkCovariantVector.h"
- 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>