ITK/Examples/ImageProcessing/Compose3DCovariantVectorImageFilter: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
(Created page with "==Compose3DCovariantVectorImageFilter.cxx== <source lang="cpp"> #include "itkImageAdaptor.h" #include "itkImageRegionIterator.h" #include "itkCompose3DCovariantVectorImageFilter....")
 
(CreateImage must be static to avoid duplicate symbols in test driver.)
Line 8: Line 8:
typedef itk::Image<float, 2> ScalarImageType;
typedef itk::Image<float, 2> ScalarImageType;


void CreateImage(ScalarImageType::Pointer image);
static void CreateImage(ScalarImageType::Pointer image);


int main(int, char *[])
int main(int, char *[])

Revision as of 15:19, 10 December 2010

Compose3DCovariantVectorImageFilter.cxx

<source lang="cpp">

  1. include "itkImageAdaptor.h"
  2. include "itkImageRegionIterator.h"
  3. include "itkCompose3DCovariantVectorImageFilter.h"

typedef itk::Image<itk::CovariantVector< float, 3>, 2> VectorImageType; typedef itk::Image<float, 2> ScalarImageType;

static void CreateImage(ScalarImageType::Pointer image);

int main(int, char *[]) {

 ScalarImageType::Pointer image = ScalarImageType::New();
 CreateImage(image);
 typedef itk::Compose3DCovariantVectorImageFilter<ScalarImageType,
                             VectorImageType> ComposeCovariantVectorImageFilterType;
 ComposeCovariantVectorImageFilterType::Pointer composeFilter = ComposeCovariantVectorImageFilterType::New();
 composeFilter->SetInput1(image);
 composeFilter->SetInput2(image);
 composeFilter->SetInput3(image);
 composeFilter->Update();
 
 itk::Index<2> index;
 index.Fill(0);
 std::cout << image->GetPixel(index) << std::endl;
 std::cout << composeFilter->GetOutput()->GetPixel(index) << std::endl;
 return EXIT_SUCCESS;

}

void CreateImage(ScalarImageType::Pointer image) {

 ScalarImageType::IndexType start;
 start.Fill(0);
 ScalarImageType::SizeType size;
 size.Fill(2);
 ScalarImageType::RegionType region;
 region.SetSize(size);
 region.SetIndex(start);
 image->SetRegions(region);
 image->Allocate();
 itk::ImageRegionIterator<ScalarImageType> imageIterator(image,image->GetLargestPossibleRegion());
 while(!imageIterator.IsAtEnd())
   {
   imageIterator.Set(1.2);
   ++imageIterator;
   }

} </source>

CMakeLists.txt

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

PROJECT(Compose3DCovariantVectorImageFilter)

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

ADD_EXECUTABLE(Compose3DCovariantVectorImageFilter Compose3DCovariantVectorImageFilter.cxx) TARGET_LINK_LIBRARIES(Compose3DCovariantVectorImageFilter ITKIO)

</source>