[ITK] [ITK-users] Saving deformation field in vector container

Matt McCormick matt.mccormick at kitware.com
Tue Sep 29 17:23:11 EDT 2015


Hi geetha,

->Reserve() [1] must be called on the VectorContainer, and the index
should start from 0.  Here is a working example:

  https://gist.github.com/2e475ad1e05c2a2a7ffb

HTH,
Matt

[1] http://www.itk.org/Doxygen/html/classitk_1_1VectorContainer.html#a0a8c1d4d56c47166f012caa0269aa0a0

On Tue, Sep 29, 2015 at 2:31 AM, geetha <s120049 at e.ntu.edu.sg> wrote:
> Hi Matt,
>
> Here's a short compilable code for it. The deformation field I'm using can be accessed from here<https://www.dropbox.com/s/3lt059gssisg72m/deformation%20field.rar?dl=0>. It fails when updating the container.
>
>
> #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 = 1;
>        typedef itk::ImageFileReader< DisplacementFieldType >  fieldReaderType;
>        DFTransformContainerType::Pointer DeffieldContainer = DFTransformContainerType::New() ;
>        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;
>
> }
>
>
> Best Regards,
> Geetha Soujanya
>
>
>
>
>
> -----
> Thanks,
> Geetha
> --
> View this message in context: http://itk-insight-users.2283740.n2.nabble.com/Saving-deformation-field-in-vector-container-tp7587905p7587931.html
> Sent from the ITK Insight Users mailing list archive at Nabble.com.
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/insight-users
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list