22 #ifndef otbVirtualDimensionality_hxx
23 #define otbVirtualDimensionality_hxx
33 template <
class TPrecision>
38 template <
class TInputImage>
42 const unsigned int nbBands = m_Covariance.rows();
45 vnl_symmetric_eigensystem<PrecisionType> eigenK(m_Covariance);
46 VectorType eigenCovariance = eigenK.D.diagonal();
47 std::sort(eigenCovariance.begin(), eigenCovariance.end());
48 eigenCovariance.flip();
50 vnl_symmetric_eigensystem<PrecisionType> eigenR(m_Correlation);
51 VectorType eigenCorrelation = eigenR.D.diagonal();
52 std::sort(eigenCorrelation.begin(), eigenCorrelation.end());
53 eigenCorrelation.flip();
55 m_NumberOfEndmembers = 0;
56 for (
unsigned int i = 0; i < nbBands; ++i)
58 if (eigenCovariance[i] > 0 && eigenCorrelation[i] > 0)
60 double sigma = std::sqrt(2.0 / m_NumberOfPixels * (eigenCovariance[i] * eigenCovariance[i] + eigenCorrelation[i] * eigenCorrelation[i]));
61 boost::math::normal normalDist(0, sigma);
62 double tau = -boost::math::quantile(normalDist, m_FAR);
63 if (eigenCorrelation[i] - eigenCovariance[i] > tau)
64 m_NumberOfEndmembers++;
69 template <
class TImage>
72 Superclass::PrintSelf(os, indent);
74 os << indent <<
"Covariance: " << m_Covariance << std::endl;
75 os << indent <<
"Correlation: " << m_Correlation << std::endl;
76 os << indent <<
"NumberOfEndmembers: " << m_NumberOfEndmembers << std::endl;