ITK/Examples/VectorImages/JoinImageFilter: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
No edit summary
(Deprecated content that is moved to sphinxe)
 
Line 1: Line 1:
==JoinImageFilter.cxx==
{{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.
<source lang="cpp">
}}
#include "itkImage.h"
#include "itkImageFileWriter.h"
#include "itkRescaleIntensityImageFilter.h"
#include "itkJoinImageFilter.h"
#include "itkVectorImageToImageAdaptor.h"
 
typedef itk::Image<unsigned char, 2> ImageType;
 
static void CreateImage(ImageType::Pointer image, unsigned char value);
 
int main(int, char *[])
{
  ImageType::Pointer image1 = ImageType::New();
  CreateImage(image1, 0);
 
  ImageType::Pointer image2 = ImageType::New();
  CreateImage(image2, 10);
 
  typedef itk::JoinImageFilter<ImageType, ImageType> JoinImageFilterType;
 
  JoinImageFilterType::Pointer joinFilter = JoinImageFilterType::New();
  joinFilter->SetInput1(image1);
  joinFilter->SetInput2(image2);
  joinFilter->Update();
 
  itk::Index<2> index;
  index[0] = 0;
  index[1] = 0;
 
  std::cout << static_cast<int>(joinFilter->GetOutput()->GetPixel(index)[0]) << std::endl;
  std::cout << static_cast<int>(joinFilter->GetOutput()->GetPixel(index)[1]) << std::endl;
 
  return EXIT_SUCCESS;
}
 
void CreateImage(ImageType::Pointer image, unsigned char value)
{
  // Create an image
  ImageType::IndexType start;
  start.Fill(0);
 
  ImageType::SizeType size;
  size.Fill(100);
 
   ImageType::RegionType region(start,size);
 
  image->SetRegions(region);
  image->Allocate();
  image->FillBuffer(value);
 
}
</source>
 
{{ITKCMakeLists|{{SUBPAGENAME}}}}

Latest revision as of 22:00, 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.