[ITK] [ITK-users] Itk Python GetParameters

Francois Budin francois.budin at kitware.com
Mon Jan 2 16:51:28 EST 2017


Hello Fabio,

The itk::OptimizerParameter class is derived from the class vnl_vector,
which allows you to get the different component of the transform it
contains using the "get( <nth_component>)" method.
The way to use it is as follow:
a=itk.AffineTransform.New()
b=a.GetParameters()
b.get(0)

If you want to have direct access to the element of the array in Python
without the use of the "get()" method, you need to download and compile one
of the latest commits of ITK (more recent than commit
991f67ee0c377d59acdedf40382b2804f068b47b merged on December 13th, 2016)
and compile ITK with the CMake option Module_BridgeNumPy set to ON to
compile the remote module NumpyBridge. Then you can simply do:

a=itk.AffineTransform.New()
b_array=itk.GetArrayFromVnlVector(a.GetParameters())

Hope this helps,

Francois

On Sat, Dec 31, 2016 at 5:13 AM, D'Isidoro Fabio <fisidoro at ethz.ch> wrote:

> Hallo,
>
>
>
> within the context of exploring the domain of an image metric
> (MeanSquaresImageMetric1.cxx), I want to check the current parameters used
> for the translation transform:
>
>
>
> parameters = transform.GetParameters()
>
> parameters[0] = dx
>
> parameters[1] = dy
>
> metric.SetParameters( parameters )
>
>
>
>
>
> If I then code:
>
>
>
>
>
> print(metric.GetParameters())
>
>
>
>
>
> I get the proxy of Swig Object, from which I can’t see the parameters.
>
>
>
>
>
> I have tried in many ways:
>
>
>
>
>
> print(metric.GetParameters()[0])
>
> print(metric.GetParameters()[1])
>
>
>
> print(metric.GetTransform().GetParameters())
>
>
>
> print(metric.GetTransform().GetParameters().GetElement(0))
>
>
>
> but none of them works.
>
>
>
> How can I get the elements from the Swig Object?
>
>
>
> Thank you!
>
>
>
> Fabio
>
>
>
> _____________________________________
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20170102/afbbcc7e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 3700 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/community/attachments/20170102/afbbcc7e/attachment.png>
-------------- next part --------------
_____________________________________
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