[ITK] [ITK-users] ImageMomentsCalculator precision

Мар'ян Климов nekto1989 at gmail.com
Thu Jul 10 13:08:43 EDT 2014


Hi.

I've been debugging one test that was showing different results on VS2012
and MinGW and found out that ImageMomentsCalculator gives different results
(Compute() method). Do I have wrongly built ITK or it really gives
different results? First difference is very small, but later it becomes
bigger and bigger (up to 4th decimal in double).

#include <itkMatrix.h>
#include <fstream>
#include <vnl/algo/vnl_symmetric_eigensystem.h>

int main()
  {
  typedef itk::Matrix<double, 3, 3> MatrixType;
  MatrixType matrix;
  matrix(0, 0) = 0.45000000000000018;
  matrix(0, 1) = -0.15000000000000036;
  matrix(0, 2) = -0.15000000000000036;
  matrix(1, 0) = -0.15000000000000036;
  matrix(1, 1) = 0.44999999999999929;
  matrix(1, 2) = -0.14999999999999858;
  matrix(2, 0) = -0.15000000000000036;
  matrix(2, 1) = -0.14999999999999858;
  matrix(2, 2) = 0.44999999999999929;

  vnl_symmetric_eigensystem<double> eigen(matrix.GetVnlMatrix());
  vnl_diag_matrix<double> diagonal_matrix = eigen.D;

#ifdef _MSC_VER
  std::ofstream output_file("C:/temp/result_vs.txt");
#else
  std::ofstream output_file("C:/temp/result_mingw.txt");
#endif
  output_file.precision(std::numeric_limits<double>::digits10 + 2);
  for (auto i = 0; i < 3; ++i)
    output_file << diagonal_matrix(i, i) << " ";
  return 0;
  }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20140710/397f9426/attachment.html>


More information about the Community mailing list