[Insight-users] Please help on python mapping.

Tuhin Sinha tk.sinha@vanderbilt.edu
Fri May 7 19:53:19 EDT 2004


Casper,

  You will have to typdef new vector image types in
Wrapping/CSwig/Common/wrap_itkImage_2D.cxx and
Wrapping/CSwig/itkCSwigImages.h.  This may give you a start:

Wrapping/CSwig/itkCSwigImages.h --
  typedef itk::Vector<float         , 2> vF2;
  typedef itk::Image<vF2         , 2> dF2;

Wrapping/CSwig/Common/wrap_itkImage_2D.cxx --
  ITK_WRAP_OBJECT2(Image, image::vF2, 2, itkImagedF2);

Now you will have access to vector images in python.

You will have to wrap some additional classes, using the newly defined
vector image types, into python to get Demons' registration up and
running, i.e.:

itkPDEDeformableRegistrationFilter
itkPDEDeformableRegistrationFunction
itkDemonsRegistrationFilter
itkDemonsRegistrationFunction
itkVectorNeighborhoodOperatorImageFilter

I am also trying to translate this script (DeformableRegistration2.cxx)
to python also.  I have gotten all the additional classes wrapped into
python, but some of the member functions are missing.  Do you have any
experience with this or any indication as to how to fix this problem? 
Thanks.

Tuhin Sinha



type

On Fri, 2004-05-07 at 13:19, Yang Wang wrote:
> Hi, all
> 
> I am trying to map the DeformableRegistration2.cxx into Python.
> However, don't know how to do the following two parts:
> (1)    typedef itk::Vector< float, Dimension >    VectorPixelType;
>  typedef itk::Image<  VectorPixelType, Dimension > DeformationFieldType;
>  typedef itk::DemonsRegistrationFilter<
>                                InternalImageType,
>                                InternalImageType,
>                                DeformationFieldType>   
> RegistrationFilterType;
>  RegistrationFilterType::Pointer filter = RegistrationFilterType::New();
> 
> (2)
> class CommandIterationUpdate : public itk::Command
>  {
>  public:
>    typedef  CommandIterationUpdate   Self;
>    typedef  itk::Command             Superclass;
>    typedef  itk::SmartPointer<CommandIterationUpdate>  Pointer;
>    itkNewMacro( CommandIterationUpdate );
>  protected:
>    CommandIterationUpdate() {};
> 
>    typedef itk::Image< float, 2 > InternalImageType;
>    typedef itk::Vector< float, 2 >    VectorPixelType;
>    typedef itk::Image<  VectorPixelType, 2 > DeformationFieldType;
> 
>    typedef itk::DemonsRegistrationFilter<
>                                InternalImageType,
>                                InternalImageType,
>                                DeformationFieldType>   
> RegistrationFilterType;
> 
>  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)
>      {
>         const RegistrationFilterType * filter =
>          dynamic_cast< const RegistrationFilterType * >( object );
>        if( typeid( event ) != typeid( itk::IterationEvent ) )
>          {
>          return;
>          }
>        std::cout << filter->GetMetric() << std::endl;
>      }
>  };
> 
> 
> CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New();
>  filter->AddObserver( itk::IterationEvent(), observer );
> 
> **************************************
> 
> Thanks in advance for any hint or help!!
> 
> 
> Yours,
> Casper
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users@itk.org
> http://www.itk.org/mailman/listinfo/insight-users




More information about the Insight-users mailing list