From: Leonardo Florez-Valencia Date: Mon, 20 Jun 2016 22:32:27 +0000 (-0500) Subject: ... X-Git-Tag: v0.1~139 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=d610d96888c9bf3f6d3ca968c3dbb821eb9db58c;p=cpPlugins.git ... --- diff --git a/lib/cpExtensions/Algorithms/IterativeGaussianModelEstimator.hxx b/lib/cpExtensions/Algorithms/IterativeGaussianModelEstimator.hxx index a297c3c..254d201 100644 --- a/lib/cpExtensions/Algorithms/IterativeGaussianModelEstimator.hxx +++ b/lib/cpExtensions/Algorithms/IterativeGaussianModelEstimator.hxx @@ -242,8 +242,15 @@ _SquaredMahalanobis( const TVector& v ) const { if( !this->m_InverseUpdated ) { - this->m_InverseUnbiasedCovariance = - this->m_UnbiasedCovariance.GetInverse( ); + double d = + double( + vnl_determinant( this->m_UnbiasedCovariance.GetVnlMatrix( ) ) + ); + if( std::fabs( d ) > double( 0 ) ) + this->m_InverseUnbiasedCovariance = + this->m_UnbiasedCovariance.GetInverse( ); + else + this->m_InverseUnbiasedCovariance.SetIdentity( ); this->m_InverseUpdated = true; } // fi