<div>I took a (very) quick look. If it is returning NULL then it appears that either your matrix is singular, or you are not calling it correctly. BTW: bool GetInverse(transform) expects the transform to be passed in and only returns true or false depending on if the matrix inversion was successful or not. YOu probably want to make a call to transform->GetInverseMatrix() instead.</div>
<div><br></div><div>Code is included below.</div><div><br></div><div>- Wes</div><div><br></div><div>// Recompute the inverse matrix (internal)</div><div>template<class TScalarType, unsigned int NInputDimensions,</div><div>
unsigned int NOutputDimensions></div><div>const typename MatrixOffsetTransformBase<TScalarType,</div><div> NInputDimensions,</div><div> NOutputDimensions>::InverseMatrixType &</div>
<div>MatrixOffsetTransformBase<TScalarType, NInputDimensions, NOutputDimensions></div><div>::GetInverseMatrix( void ) const</div><div>{</div><div> // If the transform has been modified we recompute the inverse</div>
<div> if(m_InverseMatrixMTime != m_MatrixMTime)</div><div> {</div><div> m_Singular = false;</div><div> try </div><div> {</div><div> m_InverseMatrix = m_Matrix.GetInverse();</div><div> }</div><div>
catch(...) </div><div> {</div><div> m_Singular = true;</div><div> }</div><div> m_InverseMatrixMTime = m_MatrixMTime;</div><div> }</div><div><br></div><div> return m_InverseMatrix;</div><div>}</div>
<div><br></div><div>// return an inverse transformation</div><div>template<class TScalarType, unsigned int NInputDimensions,</div><div> unsigned int NOutputDimensions></div><div>bool</div>
<div>MatrixOffsetTransformBase<TScalarType, NInputDimensions, NOutputDimensions></div><div>::GetInverse( Self * inverse) const</div><div>{</div><div> if(!inverse)</div><div> {</div><div> return false;</div><div>
}</div><div><br></div><div> this->GetInverseMatrix();</div><div> if(m_Singular)</div><div> {</div><div> return false;</div><div> }</div><div><br></div><div> inverse->m_Matrix = this->GetInverseMatrix();</div>
<div> inverse->m_InverseMatrix = m_Matrix;</div><div> inverse->m_Offset = -(this->GetInverseMatrix() * m_Offset);</div><div> inverse->ComputeTranslation();</div><div> inverse->ComputeMatrixParameters();</div>
<div><br></div><div> return true;</div><div>}</div><div><br></div><br><div class="gmail_quote">On Tue, Dec 22, 2009 at 10:04 AM, Lodron, Gerald <span dir="ltr"><<a href="mailto:Gerald.Lodron@joanneum.at">Gerald.Lodron@joanneum.at</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div>
<div dir="ltr" align="left"><font color="#0000ff" size="2" face="Arial"><span>The method is there but it always returns NULL. I
looked in the code it really always returns NULL but i think in most ways the
affine should be invertable so the code in the function should be
changed</span></font></div><br>
<div dir="ltr" lang="de" align="left">
<hr>
<font size="2" face="Tahoma"><b>Von:</b> Wes Turner [mailto:<a href="mailto:wes.turner@kitware.com" target="_blank">wes.turner@kitware.com</a>]
<br><b>Gesendet:</b> Dienstag, 22. Dezember 2009 16:02<br><b>An:</b> Lodron,
Gerald<br><b>Cc:</b> <a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a><br><b>Betreff:</b> Re:
[Insight-users] Inverse of affine not inplemented<br></font><br></div><div><div></div><div class="h5">
<div></div>
<div>There appears to be a GetInverse() method for the Affine Transform.
Can you give a better description of your problem.</div>
<div><br></div>
<div>- Wes</div>
<div><br></div><a href="http://www.itk.org/Doxygen316/html/classitk_1_1AffineTransform.html#d294a8a59b93d3663de46705490a189e" target="_blank">http://www.itk.org/Doxygen316/html/classitk_1_1AffineTransform.html#d294a8a59b93d3663de46705490a189e</a><br>
<br>
<div class="gmail_quote">On Tue, Dec 22, 2009 at 8:10 AM, Lodron, Gerald <span dir="ltr"><<a href="mailto:Gerald.Lodron@joanneum.at" target="_blank">Gerald.Lodron@joanneum.at</a>></span>
wrote:<br>
<blockquote style="border-left:#ccc 1px solid;margin:0px 0px 0px 0.8ex;padding-left:1ex" class="gmail_quote">Hello<br><br>Is there a reason for the missing GetInverse()
implementation of the affine transformation or is it a missing
issue?<br><br>Best
regards<br><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></blockquote></div><br><br clear="all"><br>-- <br>Wesley D. Turner, Ph.D.<br>
Kitware, Inc.<br>Technical
Leader<br>28 Corporate Drive<br>Clifton Park, NY 12065-8662<br>Phone:
518-881-4920<br></div></div></div>
</blockquote></div><br><br clear="all"><br>-- <br>Wesley D. Turner, Ph.D.<br>Kitware, Inc.<br>Technical Leader<br>28 Corporate Drive<br>Clifton Park, NY 12065-8662<br>Phone: 518-881-4920<br>