Thank you for the tip!<div><br></div><div>I found the solution if someone encounters a similar problem:</div><div><br></div><div>The calculation of the position vector P2 was incorrect, it should have been:</div><div><br></div>
<div>V2 = M*(V - O).</div><div><br></div><div>Now it is fine.</div><div><br clear="all"><div>MVH</div>===================================
<div>| <span style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">Patrik Brynolfsson</span></div>
<div><span style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">| Ph.D. student at Dept of Radiation Physics</span></div>
<div><span style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"><span style="font-size:small">| </span></span><span style="border-collapse:collapse;font-family:arial, sans-serif">Umeå University<br>
| SE-901 87 Umeå</span><br></div>
<div>
<div><span style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">| Sweden</span></div>
<div><span style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">| Phone: +46 (0)90 785 2296</span></div></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="border-collapse:separate;font-family:arial">===================================</span></span></font></div><br>
<br><br><div class="gmail_quote">2011/4/1 Johnson, Hans J <span dir="ltr"><<a href="mailto:hans-johnson@uiowa.edu">hans-johnson@uiowa.edu</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div bgcolor="#FFFFFF">
<div>There is an insight journal article called "ResampleInPlace". That provides code to do this.<br>
<br>
Sent from my iPad</div><div><div></div><div class="h5">
<div><br>
On Apr 1, 2011, at 5:16 AM, "Patrik Brynolfsson" <<a href="mailto:patrik.brynolfsson@radfys.umu.se" target="_blank">patrik.brynolfsson@radfys.umu.se</a>> wrote:<br>
<br>
</div>
<div></div>
<blockquote type="cite">
<div>Hello,
<div><br>
</div>
<div>I have a little problem that I think is just down to some small detail in my understanding of DICOM and ITK. I want avoid resampling an image when applying a rigid transform by applying the transform to the directional cosines (C) and the position vector
(V) of the image instead. I do this by first getting the rotation matrix (M) and the offset (O) from the transform (an Euler3DTransform) and setting the new directional cosines as the matrix multiplication of the rotation matrix and the directional cosines, </div>
<div><br>
</div>
<div>C2=M*C, </div>
<div><br>
</div>
<div>and the new position vector as </div>
<div><br>
</div>
<div>V2 = M*V + O.</div>
<div><br>
</div>
<div>I noticed that in order to get correct results I must subtract the offset O, so </div>
<div><br>
</div>
<div>V2 = M*V - O.</div>
<div><br>
</div>
<div>I check the result by resampling my new image using an identity transform and my fixed image as reference and then take the difference between them. The result is slightly worse than if I just resample my original moving image with the resulting transform
of the registration. I use bsplines = 3 when resampling in both cases. It seems that my way of applying the transform is off by a voxel or so. </div>
<div><br>
</div>
<div>What am I doing wrong? Since I wanted to add the offset instead of subtracting it I guess I don't fully understand the parameters I'm working with so I guess I'm making more mistakes. Can someone point them out to me? Maybe there is already a filter that
does what I want to do?</div>
<div><br>
</div>
<div>Thanks in advance!</div>
<div><br>
</div>
<div>Regards</div>
<div>===================================
<div>| <span style="border-collapse:collapse;font-family:arial,sans-serif;font-size:13px">Patrik Brynolfsson</span></div>
<div><span style="border-collapse:collapse;font-family:arial,sans-serif;font-size:13px">| Ph.D. student at Dept of Radiation Physics</span></div>
<div><span style="border-collapse:collapse;font-family:arial,sans-serif;font-size:13px"><span style="font-size:small">|
</span></span><span style="border-collapse:collapse;font-family:arial,sans-serif">Umeå University<br>
| SE-901 87 Umeå</span><br>
</div>
<div>
<div><span style="border-collapse:collapse;font-family:arial,sans-serif;font-size:13px">| Sweden</span></div>
<div><span style="border-collapse:collapse;font-family:arial,sans-serif;font-size:13px">| Phone: +46 (0)90 785 2296</span></div>
</div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="border-collapse:separate;font-family:arial">===================================</span></span></font></div>
<br>
</div>
</div>
</blockquote>
</div></div><blockquote type="cite">
<div><span>_____________________________________</span><br>
<span>Powered by <a href="http://www.kitware.com" target="_blank"></a><a href="http://www.kitware.com" target="_blank">www.kitware.com</a></span><br>
<span></span><br>
<span>Visit other Kitware open-source projects at</span><br>
<span><a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a></span><br>
<span></span><br>
<span>Kitware offers ITK Training Courses, for more information visit:</span><br>
<span><a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a></span><br>
<span></span><br>
<span>Please keep messages on-topic and check the ITK FAQ at:</span><br>
<span><a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a></span><br>
<span></span><br>
<span>Follow this link to subscribe/unsubscribe:</span><br>
<span><a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a></span><br>
</div>
</blockquote>
<br>
<br>
<hr>
Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged. If you are not the intended recipient, you are hereby notified that any
retention, dissemination, distribution, or copying of this communication is strictly prohibited. Please reply to the sender that you have received the message in error, then delete it. Thank you.
<hr>
</div>
<br>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br></div>