Skip to content

Instantly share code, notes, and snippets.

@thewtex
Created September 29, 2015 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thewtex/2e475ad1e05c2a2a7ffb to your computer and use it in GitHub Desktop.
Save thewtex/2e475ad1e05c2a2a7ffb to your computer and use it in GitHub Desktop.
#include <itkVectorContainer.h>
#include "itkImage.h"
#include "itkImageFileReader.h"
const unsigned int Dimension = 3;
typedef double CoordinateRepType;
typedef itk::Vector< float, Dimension > VectorType;
typedef itk::Image< VectorType, Dimension > DisplacementFieldType;
typedef itk::VectorContainer<double,DisplacementFieldType::Pointer>DFTransformContainerType;
int main( int argc, char *argv[] )
{
int inputId = 0;
typedef itk::ImageFileReader< DisplacementFieldType > fieldReaderType;
DFTransformContainerType::Pointer DeffieldContainer = DFTransformContainerType::New() ;
DeffieldContainer->Reserve( 1 );
fieldReaderType::Pointer deffield = fieldReaderType::New();
deffield->SetFileName( argv[1]);
deffield->Update();
std::cout<<"Updating container!"<<std::endl;
try
{
DeffieldContainer->SetElement( inputId++ , deffield->GetOutput() ); //Fails here
}
catch (itk::ExceptionObject &excp)
{
std::cerr << "Exception thrown while updating container" << std::endl;
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
std::cout<<"DONE!"<<std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment