ITK/Examples/VectorImages/VectorImage: 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:
This example demonstrates how to create an image with vector valued pixels. This is very similar to
{{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.
  typedef itk::Image<itk::CovariantVector<float,2> > ImageType;
}}
but the difference is that the dimensionality of the pixels of a itkVectorImage can be determined at runtime, when the dimensionality of an itk::Image<itk::CovariantVector<pixeltype,pixeldimension> > must be determined at compile time.
 
==VectorImage.cxx==
<source lang="cpp">
#include "itkVectorImage.h"
 
int main(int, char *[])
{
  // Create an image
  typedef itk::VectorImage<float, 2> ImageType;
 
  ImageType::IndexType start;
  start.Fill(0);
 
  ImageType::SizeType size;
  size.Fill(2);
 
   ImageType::RegionType region(start,size);
 
  ImageType::Pointer image = ImageType::New();
  image->SetRegions(region);
  image->SetVectorLength(2);
  image->Allocate();
 
  ImageType::IndexType pixelIndex;
  pixelIndex[0] = 1;
  pixelIndex[1] = 1;
 
  ImageType::PixelType pixelValue = image->GetPixel(pixelIndex);
 
  std::cout << "pixel (1,1) = " << pixelValue << std::endl;
 
  typedef itk::VariableLengthVector<double> VariableVectorType;
  VariableVectorType variableLengthVector;
  variableLengthVector.SetSize(2);
  variableLengthVector[0] = 1.1;
  variableLengthVector[1] = 2.2;
 
  image->SetPixel(pixelIndex, variableLengthVector);
 
  std::cout << "pixel (1,1) = " << pixelValue << std::endl;
 
  return EXIT_SUCCESS;
}
</source>
 
{{ITKCMakeLists|{{SUBPAGENAME}}}}

Latest revision as of 21:07, 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.