ITK/Examples/Utilities/PassImageToFunction: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
(Created page with "==NonSmartPointers.cxx== <source lang="cpp"> #include <itkImage.h> #include <iostream> typedef itk::Image<float, 2> ImageType; static void Test(const ImageType* input, ImageTy...")
 
(Deprecated content that is moved to sphinx)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==NonSmartPointers.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 <itkImage.h>
 
#include <iostream>
 
typedef itk::Image<float, 2> ImageType;
 
static void Test(const ImageType* input, ImageType* output);
 
int main()
{
  //ImageType* image = ImageType::New();
  ImageType::Pointer image = ImageType::New();
  itk::Index<2> start;
  start.Fill(0);
 
  itk::Size<2> size;
  size.Fill(100);
 
  itk::ImageRegion<2> region(start,size);
 
  image->SetRegions(region);
  image->Allocate();
 
  ImageType* outputImage = ImageType::New();
  //ImageType::Pointer outputImage = ImageType::New();
 
   Test(image, outputImage);
 
  return 0;
}
 
 
void Test(const ImageType* input, ImageType* output)
{
 
  if(output->GetLargestPossibleRegion() != input->GetLargestPossibleRegion()) // Crashes here
    {
    output->SetRegions(input->GetLargestPossibleRegion());
    output->Allocate();
    }
 
}
</source>
 
{{ITKCMakeLists|NonSmartPointers}}

Latest revision as of 20:31, 6 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.