[Insight-users] Inverse of affine not inplemented

Wes Turner wes.turner at kitware.com
Tue Dec 22 10:17:21 EST 2009


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.

Code is included below.

- Wes

// Recompute the inverse matrix (internal)
template<class TScalarType, unsigned int NInputDimensions,
                            unsigned int NOutputDimensions>
const typename MatrixOffsetTransformBase<TScalarType,
                               NInputDimensions,
                               NOutputDimensions>::InverseMatrixType &
MatrixOffsetTransformBase<TScalarType, NInputDimensions, NOutputDimensions>
::GetInverseMatrix( void ) const
{
  // If the transform has been modified we recompute the inverse
  if(m_InverseMatrixMTime != m_MatrixMTime)
    {
    m_Singular = false;
    try
      {
      m_InverseMatrix  = m_Matrix.GetInverse();
      }
    catch(...)
      {
      m_Singular = true;
      }
    m_InverseMatrixMTime = m_MatrixMTime;
    }

  return m_InverseMatrix;
}

// return an inverse transformation
template<class TScalarType, unsigned int NInputDimensions,
                            unsigned int NOutputDimensions>
bool
MatrixOffsetTransformBase<TScalarType, NInputDimensions, NOutputDimensions>
::GetInverse( Self * inverse) const
{
  if(!inverse)
    {
    return false;
    }

  this->GetInverseMatrix();
  if(m_Singular)
    {
    return false;
    }

  inverse->m_Matrix         = this->GetInverseMatrix();
  inverse->m_InverseMatrix  = m_Matrix;
  inverse->m_Offset         = -(this->GetInverseMatrix() * m_Offset);
  inverse->ComputeTranslation();
  inverse->ComputeMatrixParameters();

  return true;
}


On Tue, Dec 22, 2009 at 10:04 AM, Lodron, Gerald
<Gerald.Lodron at joanneum.at>wrote:

>  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
>
>  ------------------------------
> *Von:* Wes Turner [mailto:wes.turner at kitware.com]
> *Gesendet:* Dienstag, 22. Dezember 2009 16:02
> *An:* Lodron, Gerald
> *Cc:* insight-users at itk.org
> *Betreff:* Re: [Insight-users] Inverse of affine not inplemented
>
>  There appears to be a GetInverse() method for the Affine Transform.  Can
> you give a better description of your problem.
>
> - Wes
>
>
> http://www.itk.org/Doxygen316/html/classitk_1_1AffineTransform.html#d294a8a59b93d3663de46705490a189e
>
> On Tue, Dec 22, 2009 at 8:10 AM, Lodron, Gerald <Gerald.Lodron at joanneum.at
> > wrote:
>
>> Hello
>>
>> Is there a reason for the missing GetInverse() implementation of the
>> affine transformation or is it a missing issue?
>>
>> Best regards
>>
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.html
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>
>
>
> --
> Wesley D. Turner, Ph.D.
> Kitware, Inc.
> Technical Leader
> 28 Corporate Drive
> Clifton Park, NY 12065-8662
> Phone: 518-881-4920
>



-- 
Wesley D. Turner, Ph.D.
Kitware, Inc.
Technical Leader
28 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4920
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20091222/f7d84cb4/attachment-0001.htm>


More information about the Insight-users mailing list