Quantcast

Conversion from ITK to VTK Coordinate spaces

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

Conversion from ITK to VTK Coordinate spaces

sganesan

Hello


I'm trying to write a function that can reasonably convert between ITK and VTK coordinate spaces. I have a given ITK transform with my 12 parameters, (3 fixed).  

       a        b      c    x    
                             
       d      e       f     y      
                               
       g      h        i     z    

        l      m       n    1    

where (a,b,c,d,e,f,g,h,i) represent my ITK matrix, (x,y,z) is my center, and (l,m,n) is my translation.


How do I convert that to VTK format      


       a        b      c    o    
                             
       d      e       f     p      
                               
       g      h        i     q    

        0      0       0    1    

where (a,b,c,d,e,f,g,h,i) represent my VTK matrix,, and (o,p,q) is my translation.

Is there a relatively straightforward way of doing this?

Kind Regards,
Sam

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Conversion from ITK to VTK Coordinate spaces

David Gobbi
Hi Sam,

The question that you are asking does not have a straightforward answer, because VTK doesn't actually define its coordinate space... in VTK you can use whatever coordinate you want.

Since I work with DICOM images, I define my VTK world coordinate system to be the DICOM patient coordinate system (that is, I follow the convention that the +x direction is towards the left hand, the +z direction is towards the head, and +y is towards the back).  This simplifies moving data between ITK and VTK, because ITK uses the same coordinate system.

However, this means that whenever I read images into VTK, I must put the images into this coordinate system.  So, for example, I wrote a class called vtkDICOMToRAS (https://github.com/dgobbi/vtk-dicom/blob/master/Source/vtkDICOMToRAS.h) to convert images that are read by the vtkNIFTIImageReader from their native coordinate system to the DICOM coordinate system.

Most of the VTK image readers assume that the user wants a RAS-like coordinate system, but as I said, you are free to use whatever coordinate system you desire inside VTK.  A lot of people prefer RAS because it means they don't have to convert coordinate systems whenever they read an image.  I prefer using a DICOM coordinate system because I work a lot with DICOM images, and it improves interoperability with ITK.

To kind-of sort-of answer your question, the general transformation between an ITK (DICOM-like) coord system and a RAS coordinate system is as follows:

  -1  0  0  0
   0 -1  0  0
   0  0  1  0
   0  0  0  1

However, it's rarely that straightforward, because it really depends on how the data was read into VTK.

 - David




On Tue, May 9, 2017 at 9:46 AM, <[hidden email]> wrote:

Hello


I'm trying to write a function that can reasonably convert between ITK and VTK coordinate spaces. I have a given ITK transform with my 12 parameters, (3 fixed).  

       a        b      c    x    
                             
       d      e       f     y      
                               
       g      h        i     z    

        l      m       n    1    

where (a,b,c,d,e,f,g,h,i) represent my ITK matrix, (x,y,z) is my center, and (l,m,n) is my translation.


How do I convert that to VTK format      


       a        b      c    o    
                             
       d      e       f     p      
                               
       g      h        i     q    

        0      0       0    1    

where (a,b,c,d,e,f,g,h,i) represent my VTK matrix,, and (o,p,q) is my translation.

Is there a relatively straightforward way of doing this?

Kind Regards,
Sam

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Loading...