ITK/Examples/VectorImages/ImageToVectorImageFilter: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
(Unused args)
(Deprecated content that is moved to sphinxe)
 
Line 1: Line 1:
This example demonstrates how to compose a vector image from a collection of scalar images.
{{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.
 
}}
==ImageToVectorImageFilter.cxx==
<source lang="cpp">
#include "itkImage.h"
#include "itkComposeImageFilter.h"
#include "itkVectorImage.h"
 
namespace
{
typedef itk::VectorImage<unsigned char, 2> VectorImageType;
typedef itk::Image<unsigned char, 2>  ScalarImageType;
}
 
static void CreateImage(ScalarImageType::Pointer image);
 
int main(int, char *[])
{
  ScalarImageType::Pointer image0 = ScalarImageType::New();
  CreateImage(image0);
 
  ScalarImageType::Pointer image1 = ScalarImageType::New();
  CreateImage(image1);
 
  ScalarImageType::Pointer image2 = ScalarImageType::New();
  CreateImage(image2);
 
  typedef itk::ComposeImageFilter<ScalarImageType> ImageToVectorImageFilterType;
  ImageToVectorImageFilterType::Pointer imageToVectorImageFilter = ImageToVectorImageFilterType::New();
  imageToVectorImageFilter->SetInput(0, image0);
  imageToVectorImageFilter->SetInput(1, image1);
  imageToVectorImageFilter->SetInput(2, image2);
  imageToVectorImageFilter->Update();
 
  VectorImageType::Pointer vectorImage = imageToVectorImageFilter->GetOutput();
 
  return EXIT_SUCCESS;
}
 
void CreateImage(ScalarImageType::Pointer image)
{
  ScalarImageType::IndexType start;
  start.Fill(0);
   
  ScalarImageType::SizeType size;
  size.Fill(100);
 
   ScalarImageType::RegionType region(start,size);
  image->SetRegions(region);
  image->Allocate();
  image->FillBuffer(0);
 
}
</source>
 
{{ITKCMakeLists|{{SUBPAGENAME}}}}

Latest revision as of 21:33, 5 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.