[Insight-users] BUG: itkVersorRigid3DTransformOptimizer

Lodron, Gerald Gerald.Lodron at joanneum.at
Wed Nov 18 05:00:23 EST 2009


Hello,

I tested the itkVersorRigid3DTransformOptimizer. It does not call the iteration update. Here my code:

itk::Optimizer::Pointer optimizer;

typedef itk::VersorRigid3DTransformOptimizer VROptimizer;

optimizer = VROptimizer::New();
dynamic_cast<VROptimizer*>(optimizer.GetPointer())->SetNumberOfIterations(200);

CommandIterationUpdate<VROptimizer>::Pointer observer = CommandIterationUpdate<VROptimizer>::New();
optimizer->AddObserver( itk::IterationEvent(), observer );



        template<class OptimizerType>
        class CommandIterationUpdate : public itk::Command
        {
        public:
                typedef  CommandIterationUpdate                                         Self;
                typedef  itk::Command                                                           Superclass;
                typedef  itk::SmartPointer<CommandIterationUpdate>  Pointer;
                itkNewMacro( CommandIterationUpdate );
        protected:
                CommandIterationUpdate() {};

                typedef   const OptimizerType   *           OptimizerPointer;

        public:

                void Execute(itk::Object *caller, const itk::EventObject & event)
                {
                        Execute( (const itk::Object *)caller, event);
                }

                void Execute(const itk::Object * object, const itk::EventObject & event)
                {
                        OptimizerPointer optimizer =   dynamic_cast< OptimizerPointer >( object );
                        if( ! itk::IterationEvent().CheckEvent( &event ) )
                        {
                                return;
                        }
                        std::cout << "Iteration " << optimizer->GetCurrentIteration() << " \t";
                        std::cout << "Value "<< optimizer->GetValue() << " \t";
                        std::cout << "Position " << optimizer->GetCurrentPosition() << std::endl;
                }
        };



More information about the Insight-users mailing list