Problem with CenteredTransformInitializer

View: New views
8 Messages — Rating Filter:   Alert me  

Problem with CenteredTransformInitializer

by Lodron, Gerald :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

 
Hello

I try to make a rigid 3 d registration of two singed short images, i always get a compiler error when i want to use the CenteredTransformInitializer, here is my code


template <class TPixelSource=signed short,class TPixelTarget=signed short, unsigned int VImageDimension=3>

        typedef itk::Image< TPixelTarget, VImageDimension > TargetImageType;
        typedef itk::Image< TPixelSource, VImageDimension > SourceImageType;
        typedef float InternalPixelType;
        typedef itk::Image< InternalPixelType, VImageDimension > InternalImageType;

        typedef itk::MultiResolutionImageRegistrationMethod<InternalImageType, InternalImageType > RegistrationType;
        typedef typename RegistrationType::TransformType TransformType;
        typedef itk::CenteredTransformInitializer<TransformType, TargetImageType, SourceImageType > InitializerType;
               
        RegistrationType* m_Registration = RegistrationType::New();
               
        TransformType* m_Transformation = itk::AffineTransform<double, VImageDimension>::New();

        m_Registration->SetTransform(m_Transformation);

        InitializerType* m_InitTransform = InitializerType::New();
        m_InitTransform->SetTransform(   m_Transformation ); //exception


Would be great if anyone could give me a hint,

Best regards
_____________________________________
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.html

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://www.itk.org/mailman/listinfo/insight-users

Re: Problem with CenteredTransformInitializer

by Luis Ibanez :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Gerald,

Please post to the mailing list the compilation error that
you get with this code.

It will make a lot easier for us to advise you if we can
see the error message.


Also,
please note that the following construction is incorrect:

   RegistrationType * m_Registration = RegistrationType::New();

It should be:

   RegistrationType::Pointer  m_Registration = RegistrationType::New();



along the same lines, the statement:

TransformType* m_Transformation =
     itk::AffineTransform<double, VImageDimension>::New();

should be

TransformType::Pointer m_Transformation =
     itk::AffineTransform<double, VImageDimension>::New();


If you don't assign a newly created ITK object to a SmartPointer,
the object will be destroyed by the next line in the code.

If you are getting run-time errors, this misuse of the New() method
may explain what is happening with your program at run-time.
Introducing a proper use of SmartPointers may fix the problem.

---

For more information about the use of SmartPointers in ITK, please
read the introductory chapters of the ITK Software Guide:

          http://www.itk.org/ItkSoftwareGuide.pdf

and the Tutorials:

           http://www.itk.org/ITK/help/tutorials.html

in particular:
http://www.itk.org/CourseWare/Training/GettingStarted-I.pdf




    Regards,


           Luis


-----------------------------------------------------------
On Fri, Nov 6, 2009 at 6:09 AM, Lodron, Gerald
<Gerald.Lodron@...> wrote:

>
> Hello
>
> I try to make a rigid 3 d registration of two singed short images, i always get a compiler error when i want to use the CenteredTransformInitializer, here is my code
>
>
> template <class TPixelSource=signed short,class TPixelTarget=signed short, unsigned int VImageDimension=3>
>
>        typedef itk::Image< TPixelTarget, VImageDimension >                     TargetImageType;
>        typedef itk::Image< TPixelSource, VImageDimension >                     SourceImageType;
>        typedef float                                                                   InternalPixelType;
>        typedef itk::Image< InternalPixelType, VImageDimension >                InternalImageType;
>
>        typedef itk::MultiResolutionImageRegistrationMethod<InternalImageType, InternalImageType >              RegistrationType;
>        typedef typename RegistrationType::TransformType                        TransformType;
>        typedef itk::CenteredTransformInitializer<TransformType, TargetImageType, SourceImageType >             InitializerType;
>
>        RegistrationType*       m_Registration = RegistrationType::New();
>
>        TransformType* m_Transformation = itk::AffineTransform<double, VImageDimension>::New();
>
>        m_Registration->SetTransform(m_Transformation);
>
>        InitializerType* m_InitTransform = InitializerType::New();
>        m_InitTransform->SetTransform(   m_Transformation ); //exception
>
>
> Would be great if anyone could give me a hint,
>
> Best regards
> _____________________________________
> 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.html
>
> 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://www.itk.org/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.html

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://www.itk.org/mailman/listinfo/insight-users

Re: Problem with CenteredTransformInitializer

by Lodron, Gerald :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

 Thanks for your reply,

I changed the code to ::Pointer and found the error. The problem were the lines:

typedef typename RegistrationType::TransformType                        TransformType;
TransformType* m_Transformation = itk::AffineTransform<double, VImageDimension>::New();
typedef itk::CenteredTransformInitializer<TransformType, TargetImageType, SourceImageType >  InitializerType;

It seems that the RegistrationType::TransformType is "too general" for the InitializerType (i don't know how to say it otherwords). The typedef works but in the New constructor of the initializer a type was searched wich does not exist in the transformtype. When I replace the transformtype into a specific transformation, e.g.:

typedef typename itk::AffineTransform<double, VImageDimension>      TransformType;
TransformType* m_Transformation = itk::AffineTransform<double, VImageDimension>::New();

It works. I wanted to make that stuff arbitrary from the transformation, but it seems that it does not work for the initializer so i will make it so.

Best regards



-----Ursprüngliche Nachricht-----
Von: Luis Ibanez [mailto:luis.ibanez@...]
Gesendet: Montag, 09. November 2009 01:25
An: Lodron, Gerald
Cc: Insight users (insight-users@...)
Betreff: Re: [Insight-users] Problem with CenteredTransformInitializer

Hi Gerald,

Please post to the mailing list the compilation error that
you get with this code.

It will make a lot easier for us to advise you if we can
see the error message.


Also,
please note that the following construction is incorrect:

   RegistrationType * m_Registration = RegistrationType::New();

It should be:

   RegistrationType::Pointer  m_Registration = RegistrationType::New();



along the same lines, the statement:

TransformType* m_Transformation =
     itk::AffineTransform<double, VImageDimension>::New();

should be

TransformType::Pointer m_Transformation =
     itk::AffineTransform<double, VImageDimension>::New();


If you don't assign a newly created ITK object to a SmartPointer,
the object will be destroyed by the next line in the code.

If you are getting run-time errors, this misuse of the New() method
may explain what is happening with your program at run-time.
Introducing a proper use of SmartPointers may fix the problem.

---

For more information about the use of SmartPointers in ITK, please
read the introductory chapters of the ITK Software Guide:

          http://www.itk.org/ItkSoftwareGuide.pdf

and the Tutorials:

           http://www.itk.org/ITK/help/tutorials.html

in particular:
http://www.itk.org/CourseWare/Training/GettingStarted-I.pdf




    Regards,


           Luis


-----------------------------------------------------------
On Fri, Nov 6, 2009 at 6:09 AM, Lodron, Gerald
<Gerald.Lodron@...> wrote:

>
> Hello
>
> I try to make a rigid 3 d registration of two singed short images, i always get a compiler error when i want to use the CenteredTransformInitializer, here is my code
>
>
> template <class TPixelSource=signed short,class TPixelTarget=signed short, unsigned int VImageDimension=3>
>
>        typedef itk::Image< TPixelTarget, VImageDimension >                     TargetImageType;
>        typedef itk::Image< TPixelSource, VImageDimension >                     SourceImageType;
>        typedef float                                                                   InternalPixelType;
>        typedef itk::Image< InternalPixelType, VImageDimension >                InternalImageType;
>
>        typedef itk::MultiResolutionImageRegistrationMethod<InternalImageType, InternalImageType >              RegistrationType;
>        typedef typename RegistrationType::TransformType                        TransformType;
>        typedef itk::CenteredTransformInitializer<TransformType, TargetImageType, SourceImageType >             InitializerType;
>
>        RegistrationType*       m_Registration = RegistrationType::New();
>
>        TransformType* m_Transformation = itk::AffineTransform<double, VImageDimension>::New();
>
>        m_Registration->SetTransform(m_Transformation);
>
>        InitializerType* m_InitTransform = InitializerType::New();
>        m_InitTransform->SetTransform(   m_Transformation ); //exception
>
>
> Would be great if anyone could give me a hint,
>
> Best regards
> _____________________________________
> 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.html
>
> 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://www.itk.org/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.html

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://www.itk.org/mailman/listinfo/insight-users

Re: Problem with CenteredTransformInitializer

by Lodron, Gerald :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

 
I am not sure if i understand this CenteredTransformInitializer class, can anyone explain me why itk::CenteredTransformInitializer does work for itk::AffineTransform but not for itk::TranslationTransform or itk::ScaleTransform?

Maybe it is a bug?

Best regards!






-----Ursprüngliche Nachricht-----
Von: Luis Ibanez [mailto:luis.ibanez@...]
Gesendet: Montag, 09. November 2009 01:25
An: Lodron, Gerald
Cc: Insight users (insight-users@...)
Betreff: Re: [Insight-users] Problem with CenteredTransformInitializer

Hi Gerald,

Please post to the mailing list the compilation error that
you get with this code.

It will make a lot easier for us to advise you if we can
see the error message.


Also,
please note that the following construction is incorrect:

   RegistrationType * m_Registration = RegistrationType::New();

It should be:

   RegistrationType::Pointer  m_Registration = RegistrationType::New();



along the same lines, the statement:

TransformType* m_Transformation =
     itk::AffineTransform<double, VImageDimension>::New();

should be

TransformType::Pointer m_Transformation =
     itk::AffineTransform<double, VImageDimension>::New();


If you don't assign a newly created ITK object to a SmartPointer,
the object will be destroyed by the next line in the code.

If you are getting run-time errors, this misuse of the New() method
may explain what is happening with your program at run-time.
Introducing a proper use of SmartPointers may fix the problem.

---

For more information about the use of SmartPointers in ITK, please
read the introductory chapters of the ITK Software Guide:

          http://www.itk.org/ItkSoftwareGuide.pdf

and the Tutorials:

           http://www.itk.org/ITK/help/tutorials.html

in particular:
http://www.itk.org/CourseWare/Training/GettingStarted-I.pdf




    Regards,


           Luis


-----------------------------------------------------------
On Fri, Nov 6, 2009 at 6:09 AM, Lodron, Gerald
<Gerald.Lodron@...> wrote:

>
> Hello
>
> I try to make a rigid 3 d registration of two singed short images, i always get a compiler error when i want to use the CenteredTransformInitializer, here is my code
>
>
> template <class TPixelSource=signed short,class TPixelTarget=signed short, unsigned int VImageDimension=3>
>
>        typedef itk::Image< TPixelTarget, VImageDimension >                     TargetImageType;
>        typedef itk::Image< TPixelSource, VImageDimension >                     SourceImageType;
>        typedef float                                                                   InternalPixelType;
>        typedef itk::Image< InternalPixelType, VImageDimension >                InternalImageType;
>
>        typedef itk::MultiResolutionImageRegistrationMethod<InternalImageType, InternalImageType >              RegistrationType;
>        typedef typename RegistrationType::TransformType                        TransformType;
>        typedef itk::CenteredTransformInitializer<TransformType, TargetImageType, SourceImageType >             InitializerType;
>
>        RegistrationType*       m_Registration = RegistrationType::New();
>
>        TransformType* m_Transformation = itk::AffineTransform<double, VImageDimension>::New();
>
>        m_Registration->SetTransform(m_Transformation);
>
>        InitializerType* m_InitTransform = InitializerType::New();
>        m_InitTransform->SetTransform(   m_Transformation ); //exception
>
>
> Would be great if anyone could give me a hint,
>
> Best regards
> _____________________________________
> 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.html
>
> 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://www.itk.org/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.html

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://www.itk.org/mailman/listinfo/insight-users

Re: Problem with CenteredTransformInitializer

by Karthik Krishnan-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, it appears to use some typedefs such as OffsetType specific to itk::MatrixOffsetTransformBase. Sadly, itk::TranslationTransform etc aren't derived from itk::MatrixOffsetTransformBase.

Try to add the line

  typedef OutputVectorType OffsetType;

to itk::TranslationTransform and see if it works for you. If so, please send us the patch.

thanks

On Mon, Nov 9, 2009 at 1:23 PM, Lodron, Gerald <Gerald.Lodron@...> wrote:

I am not sure if i understand this CenteredTransformInitializer class, can anyone explain me why itk::CenteredTransformInitializer does work for itk::AffineTransform but not for itk::TranslationTransform or itk::ScaleTransform?

Maybe it is a bug?

Best regards!






-----Ursprüngliche Nachricht-----
Von: Luis Ibanez [mailto:luis.ibanez@...]
Gesendet: Montag, 09. November 2009 01:25
An: Lodron, Gerald
Cc: Insight users (insight-users@...)
Betreff: Re: [Insight-users] Problem with CenteredTransformInitializer

Hi Gerald,

Please post to the mailing list the compilation error that
you get with this code.

It will make a lot easier for us to advise you if we can
see the error message.


Also,
please note that the following construction is incorrect:

  RegistrationType * m_Registration = RegistrationType::New();

It should be:

  RegistrationType::Pointer  m_Registration = RegistrationType::New();



along the same lines, the statement:

TransformType* m_Transformation =
    itk::AffineTransform<double, VImageDimension>::New();

should be

TransformType::Pointer m_Transformation =
    itk::AffineTransform<double, VImageDimension>::New();


If you don't assign a newly created ITK object to a SmartPointer,
the object will be destroyed by the next line in the code.

If you are getting run-time errors, this misuse of the New() method
may explain what is happening with your program at run-time.
Introducing a proper use of SmartPointers may fix the problem.

---

For more information about the use of SmartPointers in ITK, please
read the introductory chapters of the ITK Software Guide:

         http://www.itk.org/ItkSoftwareGuide.pdf

and the Tutorials:

          http://www.itk.org/ITK/help/tutorials.html

in particular:
http://www.itk.org/CourseWare/Training/GettingStarted-I.pdf




   Regards,


          Luis


-----------------------------------------------------------
On Fri, Nov 6, 2009 at 6:09 AM, Lodron, Gerald
<Gerald.Lodron@...> wrote:
>
> Hello
>
> I try to make a rigid 3 d registration of two singed short images, i always get a compiler error when i want to use the CenteredTransformInitializer, here is my code
>
>
> template <class TPixelSource=signed short,class TPixelTarget=signed short, unsigned int VImageDimension=3>
>
>        typedef itk::Image< TPixelTarget, VImageDimension >                     TargetImageType;
>        typedef itk::Image< TPixelSource, VImageDimension >                     SourceImageType;
>        typedef float                                                                   InternalPixelType;
>        typedef itk::Image< InternalPixelType, VImageDimension >                InternalImageType;
>
>        typedef itk::MultiResolutionImageRegistrationMethod<InternalImageType, InternalImageType >              RegistrationType;
>        typedef typename RegistrationType::TransformType                        TransformType;
>        typedef itk::CenteredTransformInitializer<TransformType, TargetImageType, SourceImageType >             InitializerType;
>
>        RegistrationType*       m_Registration = RegistrationType::New();
>
>        TransformType* m_Transformation = itk::AffineTransform<double, VImageDimension>::New();
>
>        m_Registration->SetTransform(m_Transformation);
>
>        InitializerType* m_InitTransform = InitializerType::New();
>        m_InitTransform->SetTransform(   m_Transformation ); //exception
>
>
> Would be great if anyone could give me a hint,
>
> Best regards
> _____________________________________
> 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.html
>
> 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://www.itk.org/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.html

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://www.itk.org/mailman/listinfo/insight-users


_________________________________
Karthik Krishnan
R&D Engineer,
Kitware Inc.
Ph: +1 5188814919, +91 9538477060

_____________________________________
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.html

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://www.itk.org/mailman/listinfo/insight-users

Re: Problem with CenteredTransformInitializer

by Lodron, Gerald :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Oh I think my C++ vodoo is not good enough to fix that bug, i am only a poor user. Changes in the ITK code should really be made from someone which is knowing what he does, I would make more worse than better i think. I am currently in the learning phase and does not really know what 90 % of the code really does!


Von: Karthik Krishnan [mailto:karthik.krishnan@...]
Gesendet: Dienstag, 10. November 2009 08:44
An: Lodron, Gerald
Cc: Luis Ibanez; Insight users (insight-users@...)
Betreff: Re: [Insight-users] Problem with CenteredTransformInitializer

Yes, it appears to use some typedefs such as OffsetType specific to itk::MatrixOffsetTransformBase. Sadly, itk::TranslationTransform etc aren't derived from itk::MatrixOffsetTransformBase.

Try to add the line

  typedef OutputVectorType OffsetType;

to itk::TranslationTransform and see if it works for you. If so, please send us the patch.

thanks

On Mon, Nov 9, 2009 at 1:23 PM, Lodron, Gerald <Gerald.Lodron@...> wrote:

I am not sure if i understand this CenteredTransformInitializer class, can anyone explain me why itk::CenteredTransformInitializer does work for itk::AffineTransform but not for itk::TranslationTransform or itk::ScaleTransform?

Maybe it is a bug?

Best regards!






-----Ursprüngliche Nachricht-----
Von: Luis Ibanez [mailto:luis.ibanez@...]
Gesendet: Montag, 09. November 2009 01:25
An: Lodron, Gerald
Cc: Insight users (insight-users@...)
Betreff: Re: [Insight-users] Problem with CenteredTransformInitializer

Hi Gerald,

Please post to the mailing list the compilation error that
you get with this code.

It will make a lot easier for us to advise you if we can
see the error message.


Also,
please note that the following construction is incorrect:

  RegistrationType * m_Registration = RegistrationType::New();

It should be:

  RegistrationType::Pointer  m_Registration = RegistrationType::New();



along the same lines, the statement:

TransformType* m_Transformation =
    itk::AffineTransform<double, VImageDimension>::New();

should be

TransformType::Pointer m_Transformation =
    itk::AffineTransform<double, VImageDimension>::New();


If you don't assign a newly created ITK object to a SmartPointer,
the object will be destroyed by the next line in the code.

If you are getting run-time errors, this misuse of the New() method
may explain what is happening with your program at run-time.
Introducing a proper use of SmartPointers may fix the problem.

---

For more information about the use of SmartPointers in ITK, please
read the introductory chapters of the ITK Software Guide:

         http://www.itk.org/ItkSoftwareGuide.pdf

and the Tutorials:

          http://www.itk.org/ITK/help/tutorials.html

in particular:
http://www.itk.org/CourseWare/Training/GettingStarted-I.pdf




   Regards,


          Luis


-----------------------------------------------------------
On Fri, Nov 6, 2009 at 6:09 AM, Lodron, Gerald
<Gerald.Lodron@...> wrote:

>
> Hello
>
> I try to make a rigid 3 d registration of two singed short images, i always get a compiler error when i want to use the CenteredTransformInitializer, here is my code
>
>
> template <class TPixelSource=signed short,class TPixelTarget=signed short, unsigned int VImageDimension=3>
>
>        typedef itk::Image< TPixelTarget, VImageDimension >                     TargetImageType;
>        typedef itk::Image< TPixelSource, VImageDimension >                     SourceImageType;
>        typedef float                                                                   InternalPixelType;
>        typedef itk::Image< InternalPixelType, VImageDimension >                InternalImageType;
>
>        typedef itk::MultiResolutionImageRegistrationMethod<InternalImageType, InternalImageType >              RegistrationType;
>        typedef typename RegistrationType::TransformType                        TransformType;
>        typedef itk::CenteredTransformInitializer<TransformType, TargetImageType, SourceImageType >             InitializerType;
>
>        RegistrationType*       m_Registration = RegistrationType::New();
>
>        TransformType* m_Transformation = itk::AffineTransform<double, VImageDimension>::New();
>
>        m_Registration->SetTransform(m_Transformation);
>
>        InitializerType* m_InitTransform = InitializerType::New();
>        m_InitTransform->SetTransform(   m_Transformation ); //exception
>
>
> Would be great if anyone could give me a hint,
>
> Best regards
> _____________________________________
> 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.html
>
> 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://www.itk.org/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.html

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://www.itk.org/mailman/listinfo/insight-users


_________________________________
Karthik Krishnan
R&D Engineer,
Kitware Inc.
Ph: +1 5188814919, +91 9538477060

_____________________________________
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.html

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://www.itk.org/mailman/listinfo/insight-users

Re: Problem with CenteredTransformInitializer

by Luis Ibanez :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Well,
There are good reasons for not deriving the Translation transform
from the itkMatrixOffsetTransformBase.

A translation only requires N additions, (in an N-dimensional space).

If we were using the itkMatrixOffsetTransformBase for performing
a translation, we will be doing N^2 multiplications and N^2 additions
to get the equivalent result.

That said,
It is true that we could declare the OffsetType in the TranslationTransform.

I just trying doing so, and the next API changes required are:

+* SetCenter() method
+* SetTranslation() method

It seem to be a bit of a stretch to add a SetCenter method,
(which doesn't makes sense for a Translation Transform)
just for the sake of using the CenteredTransformInitializer.

A better solution seem to be to add a class:

       TranslationTransformInitializer

Please find that new class attached.


    Let us know if you find any problems with it.



        Thanks


             Luis



-------------------------------------------------------------------------------------
On Tue, Nov 10, 2009 at 2:44 AM, Karthik Krishnan
<karthik.krishnan@...> wrote:

> Yes, it appears to use some typedefs such as OffsetType specific to
> itk::MatrixOffsetTransformBase. Sadly, itk::TranslationTransform etc aren't
> derived from itk::MatrixOffsetTransformBase.
>
> Try to add the line
>
>   typedef OutputVectorType OffsetType;
>
> to itk::TranslationTransform and see if it works for you. If so, please send
> us the patch.
>
> thanks
>
> On Mon, Nov 9, 2009 at 1:23 PM, Lodron, Gerald <Gerald.Lodron@...>
> wrote:
>>
>> I am not sure if i understand this CenteredTransformInitializer class, can
>> anyone explain me why itk::CenteredTransformInitializer does work for
>> itk::AffineTransform but not for itk::TranslationTransform or
>> itk::ScaleTransform?
>>
>> Maybe it is a bug?
>>
>> Best regards!
>>
>>
>>
>>
>>
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Luis Ibanez [mailto:luis.ibanez@...]
>> Gesendet: Montag, 09. November 2009 01:25
>> An: Lodron, Gerald
>> Cc: Insight users (insight-users@...)
>> Betreff: Re: [Insight-users] Problem with CenteredTransformInitializer
>>
>> Hi Gerald,
>>
>> Please post to the mailing list the compilation error that
>> you get with this code.
>>
>> It will make a lot easier for us to advise you if we can
>> see the error message.
>>
>>
>> Also,
>> please note that the following construction is incorrect:
>>
>>   RegistrationType * m_Registration = RegistrationType::New();
>>
>> It should be:
>>
>>   RegistrationType::Pointer  m_Registration = RegistrationType::New();
>>
>>
>>
>> along the same lines, the statement:
>>
>> TransformType* m_Transformation =
>>     itk::AffineTransform<double, VImageDimension>::New();
>>
>> should be
>>
>> TransformType::Pointer m_Transformation =
>>     itk::AffineTransform<double, VImageDimension>::New();
>>
>>
>> If you don't assign a newly created ITK object to a SmartPointer,
>> the object will be destroyed by the next line in the code.
>>
>> If you are getting run-time errors, this misuse of the New() method
>> may explain what is happening with your program at run-time.
>> Introducing a proper use of SmartPointers may fix the problem.
>>
>> ---
>>
>> For more information about the use of SmartPointers in ITK, please
>> read the introductory chapters of the ITK Software Guide:
>>
>>          http://www.itk.org/ItkSoftwareGuide.pdf
>>
>> and the Tutorials:
>>
>>           http://www.itk.org/ITK/help/tutorials.html
>>
>> in particular:
>> http://www.itk.org/CourseWare/Training/GettingStarted-I.pdf
>>
>>
>>
>>
>>    Regards,
>>
>>
>>           Luis
>>
>>
>> -----------------------------------------------------------
>> On Fri, Nov 6, 2009 at 6:09 AM, Lodron, Gerald
>> <Gerald.Lodron@...> wrote:
>> >
>> > Hello
>> >
>> > I try to make a rigid 3 d registration of two singed short images, i
>> > always get a compiler error when i want to use the
>> > CenteredTransformInitializer, here is my code
>> >
>> >
>> > template <class TPixelSource=signed short,class TPixelTarget=signed
>> > short, unsigned int VImageDimension=3>
>> >
>> >        typedef itk::Image< TPixelTarget, VImageDimension >
>> >       TargetImageType;
>> >        typedef itk::Image< TPixelSource, VImageDimension >
>> >       SourceImageType;
>> >        typedef float
>> >               InternalPixelType;
>> >        typedef itk::Image< InternalPixelType, VImageDimension >
>> >        InternalImageType;
>> >
>> >        typedef
>> > itk::MultiResolutionImageRegistrationMethod<InternalImageType,
>> > InternalImageType >              RegistrationType;
>> >        typedef typename RegistrationType::TransformType
>> >        TransformType;
>> >        typedef itk::CenteredTransformInitializer<TransformType,
>> > TargetImageType, SourceImageType >             InitializerType;
>> >
>> >        RegistrationType*       m_Registration = RegistrationType::New();
>> >
>> >        TransformType* m_Transformation = itk::AffineTransform<double,
>> > VImageDimension>::New();
>> >
>> >        m_Registration->SetTransform(m_Transformation);
>> >
>> >        InitializerType* m_InitTransform = InitializerType::New();
>> >        m_InitTransform->SetTransform(   m_Transformation ); //exception
>> >
>> >
>> > Would be great if anyone could give me a hint,
>> >
>> > Best regards
>> > _____________________________________
>> > 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.html
>> >
>> > 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://www.itk.org/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.html
>>
>> 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://www.itk.org/mailman/listinfo/insight-users
>
>
> _________________________________
> Karthik Krishnan
> R&D Engineer,
> Kitware Inc.
> Ph: +1 5188814919, +91 9538477060
>


[itkTranslationTransformInitializer.h]

/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    $RCSfile: itkTranslationTransformInitializer.h,v $
  Language:  C++
  Date:      $Date: 2009-08-15 23:42:49 $
  Version:   $Revision: 1.11 $

  Copyright (c) Insight Software Consortium. All rights reserved.
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/

#ifndef __itkTranslationTransformInitializer_h
#define __itkTranslationTransformInitializer_h

#include "itkObject.h"
#include "itkObjectFactory.h"
#include "itkImageMomentsCalculator.h"

#include <iostream>

namespace itk
{

/** \class TranslationTransformInitializer
 * \brief TranslationTransformInitializer is a helper class intended to
 * initialize the center of rotation and the translation of Transforms having
 * the center of rotation among their parameters.
 *
 * This class is connected to the fixed image, moving image and transform
 * involved in the registration. Two modes of operation are possible:
 *
 * - Geometrical,
 * - Center of mass
 *
 * In the first mode, the geometrical center of the moving image is passed as
 * initial center of rotation to the transform and the vector from the center
 * of the  fixed image to the center of the moving image is passed as the
 * initial translation. This mode basically assumes that the anatomical objects
 * to be registered are centered in their respective images. Hence the best
 * initial guess for the registration is the one that superimposes those two
 * centers.
 *
 * In the second mode, the moments of gray level values are computed
 * for both images. The center of mass of the moving image is then
 * used as center of rotation. The vector between the two centers of
 * mass is passes as the initial translation to the transform. This
 * second approach assumes that the moments of the anatomical objects
 * are similar for both images and hence the best initial guess for
 * registration is to superimpose both mass centers.  Note that this
 * assumption will probably not hold in multi-modality registration.
 *
 * \ingroup Transforms
 */
template < class TTransform,
           class TFixedImage,
           class TMovingImage >
class ITK_EXPORT TranslationTransformInitializer : public Object
{
public:
  /** Standard class typedefs. */
  typedef TranslationTransformInitializer     Self;
  typedef Object                           Superclass;
  typedef SmartPointer<Self>               Pointer;
  typedef SmartPointer<const Self>         ConstPointer;
   
  /** New macro for creation of through a Smart Pointer. */
  itkNewMacro( Self );

  /** Run-time type information (and related methods). */
  itkTypeMacro( TranslationTransformInitializer, Object );

  /** Type of the transform to initialize */
  typedef TTransform                        TransformType;
  typedef typename TransformType::Pointer   TransformPointer;

  /** Dimension of parameters. */
  itkStaticConstMacro(InputSpaceDimension, unsigned int,
                      TransformType::InputSpaceDimension);
  itkStaticConstMacro(OutputSpaceDimension, unsigned int,
                      TransformType::OutputSpaceDimension);

  /** Image Types to use in the initialization of the transform */
  typedef   TFixedImage              FixedImageType;
  typedef   TMovingImage             MovingImageType;

  typedef   typename FixedImageType::ConstPointer   FixedImagePointer;
  typedef   typename MovingImageType::ConstPointer  MovingImagePointer;

  /** Moment calculators */
  typedef ImageMomentsCalculator< FixedImageType >   FixedImageCalculatorType;
  typedef ImageMomentsCalculator< MovingImageType >  MovingImageCalculatorType;

  typedef typename FixedImageCalculatorType::Pointer
                                                 FixedImageCalculatorPointer;
  typedef typename MovingImageCalculatorType::Pointer
                                                 MovingImageCalculatorPointer;


  /** Offset type. */
  typedef typename TransformType::OffsetType  OffsetType;

  /** Point type. */
  typedef typename TransformType::InputPointType   InputPointType;
 
  /** Vector type. */
  typedef typename TransformType::OutputVectorType  OutputVectorType;
 
  /** Set the transform to be initialized */
  itkSetObjectMacro( Transform,   TransformType   );

  /** Set the fixed image used in the registration process */
  itkSetConstObjectMacro( FixedImage,  FixedImageType  );

  /** Set the moving image used in the registration process */
  itkSetConstObjectMacro( MovingImage, MovingImageType );


  /** Initialize the transform using data from the images */
  virtual void InitializeTransform();

  /** Select between using the geometrical center of the images or
      using the center of mass given by the image intensities. */
  void GeometryOn() { m_UseMoments = false; }
  void MomentsOn()  { m_UseMoments = true; }

  /** Get() access to the moments calculators */
  itkGetConstObjectMacro( FixedCalculator,  FixedImageCalculatorType  );
  itkGetConstObjectMacro( MovingCalculator, MovingImageCalculatorType );

protected:
  TranslationTransformInitializer();
  ~TranslationTransformInitializer(){};

  void PrintSelf(std::ostream &os, Indent indent) const;

  itkGetObjectMacro( Transform, TransformType );

private:
  TranslationTransformInitializer(const Self&); //purposely not implemented
  void operator=(const Self&); //purposely not implemented

  TransformPointer    m_Transform;

  FixedImagePointer   m_FixedImage;

  MovingImagePointer  m_MovingImage;

  bool                m_UseMoments;

  FixedImageCalculatorPointer    m_FixedCalculator;
  MovingImageCalculatorPointer   m_MovingCalculator;

}; //class TranslationTransformInitializer


}  // namespace itk


#ifndef ITK_MANUAL_INSTANTIATION
#include "itkTranslationTransformInitializer.txx"
#endif

#endif /* __itkTranslationTransformInitializer_h */


_____________________________________
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.html

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://www.itk.org/mailman/listinfo/insight-users

itkTranslationTransformInitializer.txx (8K) Download Attachment

Parent Message unknown Re: Problem with CenteredTransformInitializer

by Luis Ibanez :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Gerald,

Thanks for pointing this out.

Yes, the Transforms:

  *  itk::ScaleTransform
  *  itk::ScaleLogarithmicTransform
  *  itk::BSplineDeformableTransform


are not suitable for the CenteredTransformInitializer.


Note however that we already have a new initializer
specialized for BSplineDeformableTransforms:


 Insight/Code/Review/
    itkBSplineDeformableTransformInitializer.h
    itkBSplineDeformableTransformInitializer.txx

These initializer is described in
the following Insight Journal paper:

http://www.insight-journal.org/browse/publication/216
http://hdl.handle.net/1926/1338



 Regards,


        Luis


----------------------------------------------------------------------------------
On Wed, Nov 11, 2009 at 2:12 AM, Lodron, Gerald
<Gerald.Lodron@...> wrote:

> Thanks,
>
> The same problem appears for the itk::ScaleTransform, itk::ScaleLogarithmicTransform and the itk::BSplineTransform.
>
> Best regards
>
>
>
>
> Well,
> There are good reasons for not deriving the Translation transform from the itkMatrixOffsetTransformBase.
>
> A translation only requires N additions, (in an N-dimensional space).
>
> If we were using the itkMatrixOffsetTransformBase for performing a translation, we will be doing N^2 multiplications and N^2 additions to get the equivalent result.
>
> That said,
> It is true that we could declare the OffsetType in the TranslationTransform.
>
> I just trying doing so, and the next API changes required are:
>
> +* SetCenter() method
> +* SetTranslation() method
>
> It seem to be a bit of a stretch to add a SetCenter method, (which doesn't makes sense for a Translation Transform) just for the sake of using the CenteredTransformInitializer.
>
> A better solution seem to be to add a class:
>
>       TranslationTransformInitializer
>
> Please find that new class attached.
>
>
>    Let us know if you find any problems with it.
>
>
>
>        Thanks
>
>
>             Luis
>
>
>
> -------------------------------------------------------------------------------------
> On Tue, Nov 10, 2009 at 2:44 AM, Karthik Krishnan <karthik.krishnan@...> wrote:
>> Yes, it appears to use some typedefs such as OffsetType specific to
>> itk::MatrixOffsetTransformBase. Sadly, itk::TranslationTransform etc
>> aren't derived from itk::MatrixOffsetTransformBase.
>>
>> Try to add the line
>>
>>   typedef OutputVectorType OffsetType;
>>
>> to itk::TranslationTransform and see if it works for you. If so,
>> please send us the patch.
>>
>> thanks
>>
>> On Mon, Nov 9, 2009 at 1:23 PM, Lodron, Gerald
>> <Gerald.Lodron@...>
>> wrote:
>>>
>>> I am not sure if i understand this CenteredTransformInitializer
>>> class, can anyone explain me why itk::CenteredTransformInitializer
>>> does work for itk::AffineTransform but not for
>>> itk::TranslationTransform or itk::ScaleTransform?
>>>
>>> Maybe it is a bug?
>>>
>>> Best regards!
>>>
>>>
>>>
>>>
>>>
>>>
>>> -----Ursprüngliche Nachricht-----
>>> Von: Luis Ibanez [mailto:luis.ibanez@...]
>>> Gesendet: Montag, 09. November 2009 01:25
>>> An: Lodron, Gerald
>>> Cc: Insight users (insight-users@...)
>>> Betreff: Re: [Insight-users] Problem with
>>> CenteredTransformInitializer
>>>
>>> Hi Gerald,
>>>
>>> Please post to the mailing list the compilation error that you get
>>> with this code.
>>>
>>> It will make a lot easier for us to advise you if we can see the
>>> error message.
>>>
>>>
>>> Also,
>>> please note that the following construction is incorrect:
>>>
>>>   RegistrationType * m_Registration = RegistrationType::New();
>>>
>>> It should be:
>>>
>>>   RegistrationType::Pointer  m_Registration =
>>> RegistrationType::New();
>>>
>>>
>>>
>>> along the same lines, the statement:
>>>
>>> TransformType* m_Transformation =
>>>     itk::AffineTransform<double, VImageDimension>::New();
>>>
>>> should be
>>>
>>> TransformType::Pointer m_Transformation =
>>>     itk::AffineTransform<double, VImageDimension>::New();
>>>
>>>
>>> If you don't assign a newly created ITK object to a SmartPointer, the
>>> object will be destroyed by the next line in the code.
>>>
>>> If you are getting run-time errors, this misuse of the New() method
>>> may explain what is happening with your program at run-time.
>>> Introducing a proper use of SmartPointers may fix the problem.
>>>
>>> ---
>>>
>>> For more information about the use of SmartPointers in ITK, please
>>> read the introductory chapters of the ITK Software Guide:
>>>
>>>          http://www.itk.org/ItkSoftwareGuide.pdf
>>>
>>> and the Tutorials:
>>>
>>>           http://www.itk.org/ITK/help/tutorials.html
>>>
>>> in particular:
>>> http://www.itk.org/CourseWare/Training/GettingStarted-I.pdf
>>>
>>>
>>>
>>>
>>>    Regards,
>>>
>>>
>>>           Luis
>>>
>>>
>>> -----------------------------------------------------------
>>> On Fri, Nov 6, 2009 at 6:09 AM, Lodron, Gerald
>>> <Gerald.Lodron@...> wrote:
>>> >
>>> > Hello
>>> >
>>> > I try to make a rigid 3 d registration of two singed short images,
>>> > i always get a compiler error when i want to use the
>>> > CenteredTransformInitializer, here is my code
>>> >
>>> >
>>> > template <class TPixelSource=signed short,class TPixelTarget=signed
>>> > short, unsigned int VImageDimension=3>
>>> >
>>> >        typedef itk::Image< TPixelTarget, VImageDimension >
>>> >       TargetImageType;
>>> >        typedef itk::Image< TPixelSource, VImageDimension >
>>> >       SourceImageType;
>>> >        typedef float
>>> >               InternalPixelType;
>>> >        typedef itk::Image< InternalPixelType, VImageDimension >
>>> >        InternalImageType;
>>> >
>>> >        typedef
>>> > itk::MultiResolutionImageRegistrationMethod<InternalImageType,
>>> > InternalImageType >              RegistrationType;
>>> >        typedef typename RegistrationType::TransformType
>>> >        TransformType;
>>> >        typedef itk::CenteredTransformInitializer<TransformType,
>>> > TargetImageType, SourceImageType >             InitializerType;
>>> >
>>> >        RegistrationType*       m_Registration =
>>> > RegistrationType::New();
>>> >
>>> >        TransformType* m_Transformation =
>>> > itk::AffineTransform<double,
>>> > VImageDimension>::New();
>>> >
>>> >        m_Registration->SetTransform(m_Transformation);
>>> >
>>> >        InitializerType* m_InitTransform = InitializerType::New();
>>> >        m_InitTransform->SetTransform(   m_Transformation );
>>> > //exception
>>> >
>>> >
>>> > Would be great if anyone could give me a hint,
>>> >
>>> > Best regards
>>> > _____________________________________
>>> > 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.html
>>> >
>>> > 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://www.itk.org/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.html
>>>
>>> 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://www.itk.org/mailman/listinfo/insight-users
>>
>>
>> _________________________________
>> Karthik Krishnan
>> R&D Engineer,
>> Kitware Inc.
>> Ph: +1 5188814919, +91 9538477060
>>
>
_____________________________________
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.html

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://www.itk.org/mailman/listinfo/insight-users