ITK/Examples/Utilities/CreateAnother: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
(Created page with "==CreateAnother.cxx== <source lang="cpp"> #include <itkAbsImageFilter.h> #include <itkImage.h> typedef itk::Image<double, 2> ImageType; void CreateImage(ImageType::Pointer image...")
 
(Deprecated content that is moved to sphinx)
 
(One intermediate revision by one other user not shown)
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|CreateAnother}}

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]