#include "itkCovariantVector.h"
#include "itkImage.h"
#include "itkImageRegionIterator.h"
#include "itkNthElementImageAdaptor.h"
#include "itkVectorImage.h"
#include "itkVectorImageToImageAdaptor.h"
static void VectorImage();
static void ImageCovariantVector();
static void VectorImageDoesNotWork();
static void ImageCovariantVectorDoesNotWork();
int main(int, char* [] )
{
return 0;
}
void ImageCovariantVector()
{
typedef itk::Image<itk::CovariantVector<unsigned char, 3>, 2> VectorImageType;
VectorImageType::Pointer image = VectorImageType::New();
itk::Index<2> corner = {{0,0}};
itk::Size<2> size = {{500,500}};
itk::ImageRegion<2> fullRegion(corner, size);
image->SetRegions(fullRegion);
image->Allocate();
typedef itk::Image<unsigned char, 2> ScalarImageType;
typedef itk::NthElementImageAdaptor<VectorImageType, ScalarImageType::PixelType> ImageAdaptorType;
typename ImageAdaptorType::Pointer adaptor = ImageAdaptorType::New();
adaptor->SelectNthElement(0);
adaptor->SetImage(image.GetPointer());
itk::ImageRegionIterator<ImageAdaptorType> imageIterator(adaptor, adaptor->GetLargestPossibleRegion());
while(!imageIterator.IsAtEnd())
{
++imageIterator;
}
}
void VectorImage()
{
typedef itk::VectorImage<unsigned char, 2> VectorImageType;
VectorImageType::Pointer image = VectorImageType::New();
itk::Index<2> corner = {{0,0}};
itk::Size<2> size = {{500,500}};
itk::ImageRegion<2> fullRegion(corner, size);
image->SetRegions(fullRegion);
image->SetNumberOfComponentsPerPixel(3);
image->Allocate();
typedef itk::Image<unsigned char, 2> ScalarImageType;
typedef itk::VectorImageToImageAdaptor<ScalarImageType::PixelType, 2> ImageAdaptorType;
typename ImageAdaptorType::Pointer adaptor = ImageAdaptorType::New();
adaptor->SetExtractComponentIndex(0);
adaptor->SetImage(image.GetPointer());
itk::ImageRegionIterator<ImageAdaptorType> imageIterator(adaptor, adaptor->GetLargestPossibleRegion());
while(!imageIterator.IsAtEnd())
{
++imageIterator;
}
}
void VectorImageDoesNotWork()
{
// typedef itk::VectorImage<unsigned char, 2> VectorImageType;
// VectorImageType::Pointer image = VectorImageType::New();
// itk::Index<2> corner = {{0,0}};
// itk::Size<2> size = {{500,500}};
// itk::ImageRegion<2> fullRegion(corner, size);
// image->SetRegions(fullRegion);
// image->SetNumberOfComponentsPerPixel(3);
// image->Allocate();
//
// typedef itk::Image<unsigned char, 2> ScalarImageType;
//
// typedef itk::NthElementImageAdaptor<VectorImageType, ScalarImageType::PixelType> ImageAdaptorType;
// typename ImageAdaptorType::Pointer adaptor = ImageAdaptorType::New();
// adaptor->SelectNthElement(0);
// adaptor->SetImage(image.GetPointer());
//
// itk::ImageRegionIterator<ImageAdaptorType> imageIterator(adaptor, adaptor->GetLargestPossibleRegion());
//
// while(!imageIterator.IsAtEnd())
// {
//
// ++imageIterator;
// }
}
void ImageCovariantVectorDoesNotWork()
{
// typedef itk::Image<itk::CovariantVector<unsigned char, 3>, 2> VectorImageType;
// VectorImageType::Pointer image = VectorImageType::New();
// itk::Index<2> corner = {{0,0}};
// itk::Size<2> size = {{500,500}};
// itk::ImageRegion<2> fullRegion(corner, size);
// image->SetRegions(fullRegion);
// image->Allocate();
//
// typedef itk::Image<unsigned char, 2> ScalarImageType;
//
// typedef itk::VectorImageToImageAdaptor<ScalarImageType::PixelType, 2> ImageAdaptorType;
// typename ImageAdaptorType::Pointer adaptor = ImageAdaptorType::New();
// adaptor->SetExtractComponentIndex(0);
// adaptor->SetImage(image.GetPointer());
//
// itk::ImageRegionIterator<ImageAdaptorType> imageIterator(adaptor, adaptor->GetLargestPossibleRegion());
//
// while(!imageIterator.IsAtEnd())
// {
//
// ++imageIterator;
// }
}