[Insight-users] Two WrapITK Questions
Gaëtan Lehmann
gaetan.lehmann at jouy.inra.fr
Sat Jan 6 13:14:28 EST 2007
Le Thu, 28 Dec 2006 18:31:20 +0100, Brian Chapman <chapmanbe at upmc.edu> a
écrit:
> I have two WrapITK questions.
>
> 1) Has anyone successfully used the
> itk.MultiResolutionImageRegistrationMethod? I am trying to translate the
> example code in MultiResImageRegistration1.cxx to Python. When I start
> the
> registration, I get the following error:
>
> Starting registration
> failed in main():
> /Users/brian/Sources/ITK/InsightToolkit-3.0.0/Code/Algorithms/itkMultiResolu
> tionImageRegistrationMethod.txx:156:
> itk::ERROR: MultiResolutionImageRegistrationMethod(0x10cf9e10): Size
> mismatch between initial parameter and transform
>
> I initialize the transform parameters with the array initialParameters:
>
> In [62]: WrapITKUtils.print_itkArray(initialParameters)
> <class 'itkArray.itkArrayDPtr'>
> 0 0.0 1 0.0
>
> In [63]: registration.SetInitialTransformParameters(initialParameters)
>
> However, if I now look at the value stored in the registration's initial
> transform parameters, its an empty array:
>
> In [64]:
> WrapITKUtils.print_itkArray(registration.GetInitialTransformParameters())
> <class 'itkArray.itkArrayDPtr'>
>
> It seems as if the Set method is not working. Any thoughts?
Can you post your code, or the part of your code which fails, so I can
test it and try to see what is going wrong ?
>
> 2) I can't figure out the template syntax for objects like the
> interpolator
> that I would define using object attributes in the interpreter as
> follows:
>
> interpolator = itk.LinearInterpolateImageFunction.IF2D.New()
>
> How would I create this using template arguments instead?
you can found in the name what the template parameters are:
IF2 is for Image< float, 2 >
D is for double
but it can be sometime difficult.
A somtime better way to go is the keys() method of the iykTemplate object
(itk.LinearInterpolateImageFunction is an itkTemplate object) to get all
the instantiation available:
3> itk.LinearInterpolateImageFunction.keys()
3>
[(<class 'itkImage.itkImageF2'>, <itkCType double>),
(<class 'itkImage.itkImageUC2'>, <itkCType double>),
(<class 'itkImage.itkImageUS2'>, <itkCType double>),
(<class 'itkImage.itkImageF3'>, <itkCType double>),
(<class 'itkImage.itkImageUC3'>, <itkCType double>),
(<class 'itkImage.itkImageUS3'>, <itkCType double>)]
or the itk.template() method to get the parameters of a given
instantiation:
4> itk.template(itk.LinearInterpolateImageFunction.IF2D)
4>
(<itkTemplate itk::LinearInterpolateImageFunction>,
(<class 'itkImage.itkImageF2'>, <itkCType double>))
So you can create it like that:
itk.LinearInterpolateImageFunction[ itk.Image[ itk.F, 2], itk.D ].New()
hope that helps,
Gaetan
--
Gaëtan Lehmann
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
tel: +33 1 34 65 29 66 fax: 01 34 65 29 09
http://voxel.jouy.inra.fr
More information about the Insight-users
mailing list