<div>Francois,</div>
<div> </div>
<div>Please submit a bug. Include the contents of your posting plus any other helpful info.</div>
<div> </div>
<div><a href="http://itk.org/Wiki/ITK_Procedure_for_Contributing_Bug_Fixes">http://itk.org/Wiki/ITK_Procedure_for_Contributing_Bug_Fixes</a></div>
<div> </div>
<div>Thanks,</div>
<div> </div>
<div>Bill<br><br></div>
<div class="gmail_quote">On Fri, Feb 8, 2008 at 4:02 PM, Francois Budin <<a href="mailto:insight.mailinglist.francois@budin.fr">insight.mailinglist.francois@budin.fr</a>> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hi all,<br><br>I was trying to compute the inverse of an affine transform (<br>itk::AffineTransform<double,3> ) using the following function:<br>
bool GetInverse (Self *inverse) const<br><br>I couldn't succeed to detect when the matrix was non-invertible. I<br>tried to verify the value returned in the boolean but it always seems<br>to be 1. I also tried to detect if any exception were thrown but it<br>
didn't catch anything.<br>My code is the following:<br><br><br> bool noninvertible=0;<br> itk::Transform<double,3,3>::Pointer inverseTransform;<br> try<br> {<br> typename AffineTransformType::Pointer affine =<br>
dynamic_cast<AffineTransformType* > ( transform.GetPointer() ) ;<br> if(affine )<br> {<br> typename AffineTransformType::Pointer<br>affinetemp=AffineTransformType::New();<br> std::cout<<affine->GetInverse(affinetemp)<<std::endl;//should<br>
print 0 if non-invertible transform;<br> inverseTransform=affinetemp;<br> }<br> else<br> {<br> typename RotationType::Pointer rigid =<br>dynamic_cast<RotationType* > ( transform.GetPointer() ) ;<br> if(rigid)<br>
{<br> typename RotationType::Pointer rigidtemp=RotationType::New();<br> std::cout<<rigid->GetInverse(rigidtemp)<<std::endl;<br> inverseTransform=rigidtemp;<br> }<br> else<br> {<br>
noninvertible=1;//I don't need to handle the other kinds of transform<br> }<br> }<br> }<br> catch(...)<br> {<br> std::cout<<"Exception Detected"<<std::endl;<br> noninvertible=1;<br>
}<br><br><br>Then I tried to write a small piece of code which copies what ITK is<br>doing to inverse an affine transform to test the inversion of the<br>matrix itself:<br><br>#include <itkMatrix.h><br><br>int main(int argnb,char* arg[])<br>
{<br>itk::Matrix<double,3,3> mat;<br>mat.Fill(0);<br>mat[0][0]=-1;<br>try<br> {<br> std::cout<<mat.GetInverse()<<std::endl;<br> }<br> catch(...)<br> {<br> std::cout<<"Singular"<<std::endl;<br>
}<br><br>return 0;<br>}<br><br>Nothing got caught, so I suspect that there is a problem somewhere and<br>that the vnl functions used to inverse the matrix does not throw any<br>exception when it is singular. If I am wrong, could anybody tell me<br>
what I should change in my code?<br>Sincerely,<br><br>Francois<br>_______________________________________________<br>Insight-users mailing list<br><a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><br><a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</blockquote></div><br>