[ITK] [ITK-users] ITK with Python Wrap: print itkMatrix proxy object
Harnish, Roy
Roy.Harnish at ucsf.edu
Mon Sep 12 17:15:44 EDT 2016
Hi Fabio,
You could try / take a look at these two functions that are related to image direction. I have had some confusion about direction matrix orientation and how to index into it, so these aren't guaranteed to be correct. Hope this helps.
Roy
def itkImage_print_direction_cosine_matrix(itkImage):
vnl_matrix = itkImage.GetDirection().GetVnlMatrix()
for i in range(3):
for j in range(3):
print "{:>8.4f}".format(vnl_matrix.get(i,j)),
print
def itkImage_set_direction_cosine_matrix(itkImage,direction_cosine_matrix):
"""
direction_cosine_matrix is assumed to be
of the form
R0 C0 S0
R1 C1 S1
R2 C2 S2
so we switch R and C to accomodate ITK's column
major order.
"""
for i in range(3):
for j in range(3):
if j == 0:
col_idx = 1
if j == 1:
col_idx = 0
if j == 2:
col_idx = 2
itkImage.GetDirection().GetVnlMatrix().set(i,j,direction_cosine_matrix[i,col_idx])
________________________________
From: Insight-users [insight-users-bounces at itk.org] on behalf of D'Isidoro Fabio [fisidoro at ethz.ch]
Sent: Monday, September 12, 2016 12:19 PM
To: insight-users at itk.org
Subject: [ITK-users] ITK with Python Wrap: print itkMatrix proxy object
Hallo,
I am using ITK with Python wrap. I would like to print the direction matrix of a 3D image obtained with the command
image.GetDirection()
However, what is printed is just
<itkMatrixPython.itkMatrixD33; proxy of <Swig object of type ‘itkMatrixD33 *’ at 0x0D3E1470> >
I understand it’s related to the wrapping, but how can I solve it?
Thank you,
Fabio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20160912/db3e9d7e/attachment.html>
-------------- 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