ITK/Examples/VectorImages/ImageToVectorImageFilter: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
(Created page with "This example demonstrates how to compose a vector image from a collection of scalar images. ==ImageToVectorImageFilter.cxx== <source lang="cpp"> #include "itkImage.h" #include "...")
 
(Deprecated content that is moved to sphinxe)
 
(4 intermediate revisions by 2 users not shown)
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 "itkImageToVectorImageFilter.h"
#include "itkVectorImage.h"
 
typedef itk::VectorImage<unsigned char, 2> VectorImageType;
typedef itk::Image<unsigned char, 2>  ScalarImageType;
 
void CreateImage(ScalarImageType::Pointer image);
 
int main(int argc, char *argv[])
{
  ScalarImageType::Pointer image0 = ScalarImageType::New();
  CreateImage(image0);
 
  ScalarImageType::Pointer image1 = ScalarImageType::New();
  CreateImage(image1);
 
  ScalarImageType::Pointer image2 = ScalarImageType::New();
  CreateImage(image2);
 
  typedef itk::ImageToVectorImageFilter<ScalarImageType> ImageToVectorImageFilterType;
  ImageToVectorImageFilterType::Pointer imageToVectorImageFilter = ImageToVectorImageFilterType::New();
  imageToVectorImageFilter->SetNthInput(0, image0);
  imageToVectorImageFilter->SetNthInput(1, image1);
  imageToVectorImageFilter->SetNthInput(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|ImageToVectorImageFilter}}

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.