[ITK-users] VNL matrix with the Python wrapper

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[ITK-users] VNL matrix with the Python wrapper

g.lemaitre58
Hi All,

I am using the python wrapper of itk to manipulate. I checked the quick start guide (http://itkpythonpackage.readthedocs.io/en/latest/Quick_start_guide.html#usage) to go from numpy to vnl matrices and vice-versa. However, I got into trouble when trying to use those utils with itk images. As a short example:

```python
>>> import numpy as np

>>> img = np.random.random((100, 100, 100))
>>> img_itk = itk.GetImageFromArray(img)

>>> vnl_matrix = img_itk.GetDirection().GetVnlMatrix()
>>> type(vnl_matrix)
vnl_matrix_fixedPython.vnl_matrix_fixedD_3_3

>>> itk.GetArrayFromVnlMatrix(vnl_matrix)

TypeError: in method 'itkPyVnlD__GetArrayViewFromVnlMatrix', argument 1 of type 'vnl_matrixD *'
```

So what would the proper way of converting this matrix into a numpy array or view.

Cheers,
--
Guillaume Lemaitre
INRIA Saclay - Parietal team
Center for Data Science Paris-Saclay
https://glemaitre.github.io/

The ITK community is transitioning from this mailing list to discourse.itk.org. Please join us there!
________________________________
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:
https://itk.org/mailman/listinfo/insight-users
Reply | Threaded
Open this post in threaded view
|

Re: [ITK-users] VNL matrix with the Python wrapper

Dženan Zukić
Hi Guillaume,

we have switched to discourse forum for discussion. Can you repost your question there?

Thanks,
Dženan

On Sun, Feb 25, 2018 at 10:26 AM, Guillaume Lemaître <[hidden email]> wrote:
Hi All,

I am using the python wrapper of itk to manipulate. I checked the quick start guide (http://itkpythonpackage.readthedocs.io/en/latest/Quick_start_guide.html#usage) to go from numpy to vnl matrices and vice-versa. However, I got into trouble when trying to use those utils with itk images. As a short example:

```python
>>> import numpy as np

>>> img = np.random.random((100, 100, 100))
>>> img_itk = itk.GetImageFromArray(img)

>>> vnl_matrix = img_itk.GetDirection().GetVnlMatrix()
>>> type(vnl_matrix)
vnl_matrix_fixedPython.vnl_matrix_fixedD_3_3

>>> itk.GetArrayFromVnlMatrix(vnl_matrix)

TypeError: in method 'itkPyVnlD__GetArrayViewFromVnlMatrix', argument 1 of type 'vnl_matrixD *'
```

So what would the proper way of converting this matrix into a numpy array or view.

Cheers,
--
Guillaume Lemaitre
INRIA Saclay - Parietal team
Center for Data Science Paris-Saclay
https://glemaitre.github.io/

The ITK community is transitioning from this mailing list to discourse.itk.org. Please join us there!
________________________________
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:
https://itk.org/mailman/listinfo/insight-users



The ITK community is transitioning from this mailing list to discourse.itk.org. Please join us there!
________________________________
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:
https://itk.org/mailman/listinfo/insight-users