ITK/Examples/Utilities/PassImageToFunction: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
(Did not compile)
(Deprecated content that is moved to sphinx)
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
==PassImageToFunction.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 myStandardPointer(const ImageType* input)
{
}
 
static void mySmartPointer(const ImageType::Pointer input)
{
}
 
template <typename TImage>
static void TemplateSmartPointer(const typename TImage::Pointer input)
{
}
 
template <typename TImage>
static void TemplateStandardPointer(const TImage* input)
{
}
 
int main(int, char *[])
{
  ImageType::Pointer image = ImageType::New();
  itk::Index<2> corner = {{0,0}};
  itk::Size<2> size = {{10,10}};
  itk::ImageRegion<2> region(corner,size);
  image->SetRegions(region);
  image->Allocate();
 
  // A function that accepts a standard pointer can be passed either a standard or a smart pointer
  myStandardPointer(image.GetPointer());
  myStandardPointer(image);
 
  // A function that accepts a smart pointer can be passed either a standard or a smart pointer
   mySmartPointer(image.GetPointer());
  mySmartPointer(image);
 
  return 0;
}
</source>
 
{{ITKCMakeLists|PassImageToFunction}}

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.