Cast Vector Image to Another Type#

Synopsis#

Cast a VectorImage to another type of VectorImage.

Results#

Warning

Fix Errors Example contains errors needed to be fixed for proper output.

Code#

C++#

#include "itkVectorImage.h"
#include "itkCastImageFilter.h"

int
main(int /*argc*/, char * /*argv*/[])
{
  typedef itk::VectorImage<unsigned char, 2> UnsignedCharVectorImageType;
  typedef itk::VectorImage<float, 2>         FloatVectorImageType;

  auto image = FloatVectorImageType::New();

  typedef itk::CastImageFilter<FloatVectorImageType, UnsignedCharVectorImageType> CastImageFilterType;
  auto vectorCastImageFilter = CastImageFilterType::New();
  vectorCastImageFilter->SetInput(image);
  vectorCastImageFilter->Update();

  return EXIT_SUCCESS;
}

Classes demonstrated#

template<typename TPixel, unsigned int VImageDimension = 3>
class VectorImage : public itk::ImageBase<VImageDimension>

Templated n-dimensional vector image class.

This class differs from Image in that it is intended to represent multiple images. Each pixel represents k measurements, each of datatype TPixel. The memory organization of the resulting image is as follows: … Pi0 Pi1 Pi2 Pi3 P(i+1)0 P(i+1)1 P(i+1)2 P(i+1)3 P(i+2)0 … where Pi0 represents the 0th measurement of the pixel at index i.

Conceptually, a VectorImage< TPixel, 3 > is the same as a Image< VariableLengthVector< TPixel >, 3 >. The difference lies in the memory organization. The latter results in a fragmented organization with each location in the Image holding a pointer to an VariableLengthVector holding the actual pixel. The former stores the k pixels instead of a pointer reference, which apart from avoiding fragmentation of memory also avoids storing a 8 bytes of pointer reference for each pixel. The parameter k can be set using SetVectorLength.

The API of the class is such that it returns a pixeltype VariableLengthVector< TPixel > when queried, with the data internally pointing to the buffer. (the container does not manage the memory). Similarly SetPixel calls can be made with VariableLengthVector< TPixel >.

The API of this class is similar to Image.

Caveats:

When using Iterators on this image, you cannot use the it.Value(). You must use Set/Get() methods instead.

Note

This work is part of the National Alliance for Medical Image Computing (NAMIC), funded by the National Institutes of Health through the NIH Roadmap for Medical Research, Grant U54 EB005149.

See

DefaultVectorPixelAccessor

See

DefaultVectorPixelAccessorFunctor

See

VectorImageToImagePixelAccessor

See

VectorImageToImageAdaptor

See

Image

See

ImportImageContainer

ITK Sphinx Examples:

See itk::VectorImage for additional documentation.