ITK/Examples/Utilities/CreateAnother: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
No edit summary
(Deprecated content that is moved to sphinx)
 
Line 1: Line 1:
==CreateAnother.cxx==
{{warning|1=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.
<source lang="cpp">
}}
#include <itkAbsImageFilter.h>
#include <itkImage.h>


typedef itk::Image<double, 2> ImageType;
[https://itk.org/ITKExamples[ITK Sphinx Examples]]
void CreateImage(ImageType::Pointer image);
 
int main(int, char*[])
{
 
  typedef itk::AbsImageFilter<ImageType, ImageType> FilterType;
  FilterType::Pointer filter = FilterType::New();
  FilterType::Pointer filter2 = dynamic_cast<FilterType*>(filter->CreateAnother().GetPointer());
 
  ImageType::Pointer image = ImageType::New();
  CreateImage(image);
 
  filter2->SetInput(image);
  filter2->Update();
 
  itk::Index<2> index;
  index.Fill(0);
 
  std::cout << filter2->GetOutput()->GetPixel(index) << std::endl;
 
  return EXIT_SUCCESS;
}
 
void CreateImage(ImageType::Pointer image)
{
  ImageType::IndexType start;
  start.Fill(0);
 
  ImageType::SizeType size;
  size.Fill(2);
 
  ImageType::RegionType region(start,size);
 
  image->SetRegions(region);
  image->Allocate();
  image->FillBuffer(-2);
}
</source>
 
{{ITKCMakeLists|{{SUBPAGENAME}}}}

Latest revision as of 17:01, 31 May 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.

[ITK Sphinx Examples]