コード例 #1
0
// computes the weighted fiducial registration error
double ComputeWeightedFRE (  vtkPoints* X,
                             vtkPoints* Y,
                             const Matrix3x3List &CovarianceMatricesMoving,
                             const Matrix3x3List &CovarianceMatricesFixed,
                             double FRENormalizationFactor,
                             Matrix3x3List& WeightMatrices,
                             const Matrix3x3& rotation,
                             const itk::Vector<double,3>& translation
                           )
{
  double FRE = 0;
  //compute weighting matrices
  calculateWeightMatrices( CovarianceMatricesMoving,
                           CovarianceMatricesFixed,
                           WeightMatrices,
                           rotation );

#pragma omp parallel for reduction(+:FRE)
  for (unsigned int i = 0; i < WeightMatrices.size(); ++i)
  {
    //convert to itk data types (nessecary since itk 4 migration)
    itk::Vector<double,3> converted_MovingPoint;
    double point[3];
    X->GetPoint(i,point);
    converted_MovingPoint[0] = point[0];
    converted_MovingPoint[1] = point[1];
    converted_MovingPoint[2] = point[2];

    // transform point
    itk::Vector<double,3> p = rotation * converted_MovingPoint + translation;

    Y->GetPoint(i,point);
    p[0] -= point[0];
    p[1] -= point[1];
    p[2] -= point[2];

    //do calculation
    const itk::Vector<double,3> D = WeightMatrices.at(i) * p;
    FRE += (D[0] * D[0] + D[1] * D[1] + D[2] * D[2]);
  }

  FRE /= WeightMatrices.size();
  FRE = FRENormalizationFactor * sqrt(FRE);

  return FRE;
}