/*========================================================================= Program: Tensor ToolKit - TTK Module: $URL$ Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) INRIA 2010. All rights reserved. See LICENSE.txt for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _itk_TensorToLogFAFunction_txx_ #define _itk_TensorToLogFAFunction_txx_ #include "itkTensorToLogFAFunction.h" #include "vnl/vnl_trace.h" namespace itk { template typename TensorToLogFAFunction::OutputPixelType TensorToLogFAFunction ::ComputeScalar (const InputPixelType & T) const { typedef typename TInputPixelType::ComponentType InputScalarType; //vnl_matrix M = T.Log().GetVnlMatrix(); vnl_matrix L = (T.Log()).GetVnlMatrix(); InputScalarType lt = static_cast( vnl_trace(L) / static_cast(InputPixelType::Dimension) ); InputPixelType eye; vnl_matrix EYE = eye.GetVnlMatrix(); EYE.set_identity(); vnl_matrix TOT = lt*lt*EYE + L*L -lt*static_cast(2.0)*L; OutputPixelType fa = static_cast ( tanh (sqrt ( vnl_trace (TOT) )) ); return fa; } }// end of namespace #endif