<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">


<META content="MSHTML 6.00.2800.1498" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=938372012-27052005><FONT face=Arial color=#0000ff 
size=2>Yu,</FONT></SPAN></DIV>
<DIV><SPAN class=938372012-27052005><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=938372012-27052005><FONT face=Arial color=#0000ff size=2>&nbsp; 
When moving to Matlab from ITK, remember that Matlab uses row-colum-slice 
(i,j,k) coordinates&nbsp;for indexing while ITK uses x,y,z directly.&nbsp; Thus 
X and Y are switched and you'll need to permute your columns in the Rotation 
matrix and the rows in the Translation column vector.&nbsp; However, I may be a 
day late and a dollar short on this as I joined the topic 
late.</FONT></SPAN></DIV>
<DIV><SPAN class=938372012-27052005><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=938372012-27052005><FONT face=Arial color=#0000ff 
size=2>-dan</FONT></SPAN></DIV>
<BLOCKQUOTE>
  <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma 
  size=2>-----Original Message-----<BR><B>From:</B> 
  insight-users-bounces+blezek=crd.ge.com@itk.org 
  [mailto:insight-users-bounces+blezek=crd.ge.com@itk.org]<B>On Behalf Of </B>Yu 
  Qi<BR><B>Sent:</B> Thursday, May 26, 2005 5:23 PM<BR><B>To:</B> insight 
  insight<BR><B>Subject:</B> Re: [Insight-users] FW: How to convert 
  VersorRigid3DTransform tovtkTransform<BR><BR></FONT></DIV>
  <DIV>
  <DIV>Hi Luis,</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>Thank you!</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>In SPM, the equations to transform the moving image is as follows</DIV>
  <DIV><FONT color=#00007f>x1=R00*x+R01*y+R02*z+Trans0</FONT></DIV>
  <DIV><FONT color=#00007f>y1=R10*x+R11*y+R12*z+Trans1</FONT></DIV>
  <DIV><FONT color=#00007f>z1=R20*x+R21*y+R22*z+Trans2</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV>But SPM integrates spacing info into the rotation 3X3 matrix.</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>I compared the result from ITK and the one from SPM, </DIV>
  <DIV><FONT color=#00407f><FONT color=#000000>I found</FONT> 
  ITKrotation*ITKspacing</FONT> is very close to the <FONT 
  color=#00007f>Ratation</FONT> matrix in SPM and the translations are also very 
  close.</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>But I can not obtain a good transform in SPM using ITK result.</DIV>
  <DIV>Do you think there will be other reasons for this? like the interpolation 
  method (default setting in SPM is linear and I use linear in ITK)?</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>Best regards,</DIV>
  <DIV>Yu Qi</DIV>
  <DIV><BR><BR><B><I>Luis Ibanez &lt;luis.ibanez@kitware.com&gt;</I></B> 
  Ð´µÀ£º</DIV>
  <BLOCKQUOTE class=replbq 
  style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid"><BR>Hi 
    Yu,<BR><BR>I'm not familiar enough with SPM to give you a good advice 
    here.<BR><BR>But in general the part that needs to be transposed is just 
    the<BR>3x3 Matrix containing the rotational part of the 
    transform.<BR><BR>This may or may not be enough for SPM, you may end up 
    needing a<BR>full 4x4 transpose.<BR><BR>Note that you don't necessarily need 
    to transpose the transform.<BR>This is only if you find that the 
    representation of the transform<BR>in ITK uses a different standard from the 
    one present in SPM.<BR><BR><BR>Sorry for not being of much help in this 
    issue,<BR><BR><BR>Luis<BR><BR><BR><BR>--------------------------------------------------------------<BR>Yu 
    Qi wrote:<BR><BR>&gt; Hi Luis,<BR>&gt; <BR>&gt; I am alsoo trying to export 
    the transform in ITK to other applications, <BR>&gt; but to SPM rather tan 
    VTK.<BR>&gt; <BR>&gt; One question I want to ask is<BR>&gt; ca! n I simply 
    use the a 4X4 matrix as follows to transform a image?<BR>&gt; | last 
    translationX |<BR>&gt; | GetRotationMatrix 3X3 last translationY |<BR>&gt; | 
    last translationZ |<BR>&gt; | 0 0 0 1 |<BR>&gt; <BR>&gt; and you mentioned 
    transpose, why do we need transpose?<BR>&gt; <BR>&gt; <BR>&gt; Thank 
    you!<BR>&gt; Best regards,<BR>&gt; Yu Qi<BR>&gt; <BR>&gt; <BR>&gt; */Luis 
    Ibanez <LUIS.IBANEZ@KITWARE.COM>/* Ð´µÀ£º<BR>&gt; <BR>&gt; <BR>&gt; Hi 
    Toon,<BR>&gt; <BR>&gt; <BR>&gt; What you are doing seems to be 
    reasonable.<BR>&gt; <BR>&gt; The only thing that can be wrong in your 
    process is<BR>&gt; that the Matrix may need to be transposed.<BR>&gt; 
    <BR>&gt; <BR>&gt; However, before we go there, could you please<BR>&gt; 
    share with us the evidence that lead you to think<BR>&gt; that the 
    transformation is not correct ?<BR>&gt; <BR>&gt; <BR>&gt; If you are 
    obtaining the Versor transform as the<BR>&gt; result of an image 
    registration process in ITK,<BR>&gt; chances are that you are being co! 
    nfused by the<BR>&gt; direction in which Transforms are computed in 
    ITK.<BR>&gt; <BR>&gt; <BR>&gt; Please let us know,<BR>&gt; <BR>&gt; <BR>&gt; 
    Thanks<BR>&gt; <BR>&gt; <BR>&gt; Luis<BR>&gt; <BR>&gt; <BR>&gt; 
    -------------------<BR>&gt; Toon Huysmans wrote:<BR>&gt; <BR>&gt; &gt; 
    Hi,<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt;; I have registered 
    two images and I have the result in a<BR>&gt; &gt; VersorRigid3DTransform, 
    now I would like to transform some<BR>&gt; vtkPolyData<BR>&gt; &gt; using 
    this transform. I believe! that VersorRigid3DTransform<BR>&gt; contains 
    a<BR>&gt; &gt; rotation (the versor) and a translation, so I set up a 4x4 
    matrix,<BR>&gt; &gt; containing the rotation and translation as 
    follows:<BR>&gt; &gt;<BR>&gt; &gt; | R11 R12 R13 Tx |<BR>&gt; &gt;<BR>&gt; 
    &gt; | R21 R22 R23 Ty |<BR>&gt; &gt;<BR>&gt; &gt; | R31 R32 R33 Tz |<BR>&gt; 
    &gt;<BR>&gt; &gt; | 0 0 0 1 |<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; 
    &gt; I get the rotation matrix R using<BR>&gt; &gt; 
    VersorRigid3DTransform::GetRotationMatrix<BR>&gt; &gt; ,<BR>&gt; &gt; and 
    the translation part using VersorRigid3DTransform::GetOffset<BR>&gt; &gt; 
    .<BR>&gt; &gt; Then I use vtkTransform::SetMatrix to set the transform for 
    the<BR>&gt; &gt; polydata, and I use<BR>&gt; &gt;<BR>&gt; &gt; 
    vtkTransformPolyDataFilter to transform the polydata. But the<BR>&gt; resul! 
    t is<BR>&gt; &gt; not as expected, i.e. the transformation is not 
    correct.<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt; Does anyone 
    have any clues on how to do it the right way?<BR>&gt; &gt;<BR>&gt; 
    &gt;<BR>&gt; &gt;<BR>&gt; &gt; Many thanks,<BR>&gt; &gt;<BR>&gt; 
    &gt;<BR>&gt; &gt;<BR>&gt; &gt; Toon Huysmans.<BR>&gt; &gt;<BR>&gt; 
    &gt;<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt; 
    ¥                                                     ?lt;br&gt;&gt;<BR>&gt; &gt; ?Postal Address: 
    ?lt;br&gt;&gt;<BR>&gt; &gt; ? ?lt;br&gt;&gt;<BR>&gt; &gt; ?Vision Lab, 
    Department of Physics ?lt;br&gt;&gt;<BR>&gt; &gt; ?Universit! y of Antwerp 
    (CMI) ?lt;br&gt;&gt;<BR>&gt; &gt; ?Groenenborgerlaan 171 (U306) 
    ?lt;br&gt;&gt;<BR>&gt; &gt; ?B-2020 Antwerp, Belgium ?lt;br&gt;&gt;<BR>&gt; 
    &gt; 
    °€EUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUR?lt;br&gt;&gt;<BR>&gt; 
    &gt; ?Tel: +32 (0) 3 265 32 24 ?lt;br&gt;&gt;<BR>&gt; &gt; 
    °€EUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUR?lt;br&gt;&gt;<BR>&gt; 
    &gt; ?Fax: +32 (0) 3 265 33 18 ?lt;br&gt;&gt;<BR>&gt; &gt; 
    °€EUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUR?lt;br&amp;g! 
    t;&gt;<BR>&gt; &gt; ?Email: toon.huysmans@ua.ac.be<BR>&gt; &gt; 
    ?lt;br&gt;&gt;<BR>&gt; &gt; 
    °€EUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUREUR?lt;br&gt;&gt;<BR>&gt; 
    &gt; ?Web: http://webhost.ua.ac.be/visielab/staff/tohu/ 
    ?lt;br&gt;&gt;<BR>&gt; &gt; 
    «                                                     ?lt;br&gt;&gt;<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; 
    &gt;<BR>&gt; &gt;<BR>&gt; 
    ------------------------------------------------------------------------<BR>&gt; 
    &gt;<BR>&gt; &gt; ________________________________________________<BR>&gt; 
    &gt; Insight-users mailing list<BR>&gt; &gt; Insight-users@itk.org<BR>&gt; 
    &gt; http://www.itk.org/mailman/listinfo/insight-users<BR>&gt; <BR>&gt; 
    <BR>&gt; <BR>&gt; _______________________________________________<BR>&gt; 
    Insight-users mailing list<BR>&gt; Insight-users@itk.org<BR>&gt; 
    http://www.itk.org/mailman/listinfo/insight-users<BR>&gt; <BR>&gt; <BR>&gt; 
    ------------------------------------------------------------------------<BR>&amp;! 
    gt; *Do You Yahoo!?*<BR>&gt; 150ÍòÇúMP3·è¿ñËÑ£¬´øÄú´³ÈëÒôÀÖµîÌà<HTTP: 
    music.yisou.com><BR>&gt; ÃÀÅ®Ã÷ÐÇÓ¦Óо¡ÓУ¬ËѱéÃÀͼ¡¢ÑÞͼºÍ¿áͼ <HTTP: image.yisou.com><BR>&gt; 
    1G¾ÍÊÇ1000Õ×£¬ÑÅ»¢µçÓÊ×ÔÖúÀ©ÈÝ£¡ <BR>&gt; <HTTP: cn.rd.yahoo.com mail_cn tag 1g *http: 
    cn.mail.yahoo.com event mail_1g /><BR>&gt; <BR><BR><BR><BR></BLOCKQUOTE></DIV>
  <P><BR>
  <HR SIZE=1>
  <B>Do You Yahoo!?</B><BR><A href="http://music.yisou.com" 
  target=blank>150ÍòÇúMP3·è¿ñËÑ£¬´øÄú´³ÈëÒôÀÖµîÌÃ</A><BR><A href="http://image.yisou.com" 
  target=blank>ÃÀÅ®Ã÷ÐÇÓ¦Óо¡ÓУ¬ËѱéÃÀͼ¡¢ÑÞͼºÍ¿áͼ</A><BR><A 
  href="http://cn.rd.yahoo.com/mail_cn/tag/1g/*http://cn.mail.yahoo.com/event/mail_1g/" 
  target=blank>1G¾ÍÊÇ1000Õ×£¬ÑÅ»¢µçÓÊ×ÔÖúÀ©ÈÝ£¡</A></BLOCKQUOTE></BODY></HTML>