dicoptimizerfalm.hpp

Source: src/pyvale/dic/cpp/dicoptimizerfalm.hpp.

class OptimizerFALM : public OptimizerBase

Public Functions

OptimizerFALM(util::EShapeFunc shape_func, util::ECorrCrit cost_func, int max_iter, double precision, double threshold, int ss_size)
virtual OptResult solve(const double cx, const double cy, Subset<double> &ss_ref, Subset<double> &ss_def, const Interpolator &interp_ref, const Interpolator &interp_def, const bool check_on_thresh = false) override

Private Functions

void set_cost_function(util::ECorrCrit corr_crit)

This function gets called before the corrolation optimization starts. Sets the function pointer for the user specified shape function.

Parameters:

corr_crit – [in] correlation criteria enum.

void debug_print(const int ss_x, const int ss_y, int iter, double costp, double ftol, double xtol)
Parameters:
  • ss_x –

  • ss_y –

void ssd(const Subset<double> &ss_ref, Subset<double> &ss_def, const Interpolator &interp_def, const double cx, const double cy)

calcutes the Sum of Squared Differences (SSD) between reference and deformed subsets.

Parameters:
  • ss_ref – [in] reference subset

  • ss_def – [inout] deformed subset

  • interp_def – [in] interpolator for deformed image

  • cx – [in] x coordinate at subset centre

  • cy – [in] y coordinate at subset centre

void nssd(const Subset<double> &ss_ref, Subset<double> &ss_def, const Interpolator &interp_def, const double cx, const double cy)

calcutes the Normalized Sum of Squared Differences (NSSD) between reference and deformed subsets.

Parameters:
  • ss_ref – [in] reference subset

  • ss_def – [inout] deformed subset

  • interp_def – [in] interpolator for deformed image

  • cx – [in] x coordinate at subset centre

  • cy – [in] y coordinate at subset centre

void znssd(const Subset<double> &ss_ref, Subset<double> &ss_def, const Interpolator &interp_def, const double cx, const double cy)

calcutes the Zero Normalized Sum of Squared Differences (ZNSSD) between reference and deformed subsets.

Parameters:
  • ss_ref – [in] reference subset

  • ss_def – [inout] deformed subset

  • interp_def – [in] interpolator for deformed image

  • cx – [in] x coordinate at subset centre

  • cy – [in] y coordinate at subset centre

bool invert_matrix(const std::vector<double> &matrix, std::vector<double> &inverse, std::vector<double> &augmented, int num_params)

Inverts square matrix using Gauss-Jordan elimination.

Parameters:
  • matrix – [in]

  • inverse – [out]

  • augmented – [in]

  • num_params – [in] Number of shape function parameters (2 for rigid, 6 for affine, …)

Returns:

true Matrix inversion was successful

Returns:

false Matrix inversion failed

void update_shapefunc_parameters(std::vector<double> &pdp, std::vector<double> &p, std::vector<double> &dp, std::vector<double> &invH, std::vector<double> &g, int num_params)

Updates the shape function parameters based on the current and updated parameters.

Parameters:
  • pdp – [out] shape function parameters for P+deltaP

  • p – [in] current shape function parameters P

  • dp – [out] the change in shape function for based on the Hessian and gradient

  • invH – [in] inverse of the Hessian matrix

  • g – [in] gradient vector

  • num_params – [in] Number of shape function parameters (2 for rigid, 6 for affine, …)

void update_lambda(double costp, double costpdp, std::vector<double> &p, std::vector<double> &pdp, double &lambda, int num_params)
Parameters:
  • costp – [in] cost value for current shape function parameters P

  • costpdp – [in] cost value for updated shape function parameters P+deltaP

  • p – [out] shape function parameters for P

  • pdp – [in] shape function parameters for P+deltaP

  • lambda – Optimization damping factor

  • num_params – [in] Number of shape function parameters (2 for rigid, 6 for affine, …)

void populate_hessian_lower_tri(std::vector<double> &H, double lambda, int num_params)

Populates the lower triangular part of the Hessian matrix, H.

Parameters:
  • H – [inout] Hessian matrix

  • lambda – [out] Optimization damping factor

  • num_params – [in] Number of shape function parameters (2 for rigid, 6 for affine, …)

Private Members

util::ECorrCrit criteria
double costp
double costpdp
bool cost_valid
std::vector<double> g
std::vector<double> dfdp
std::vector<double> dfdx
std::vector<double> dfdy
std::vector<double> H
std::vector<double> invH
std::vector<double> augmented
double lambda
const double precision
const double threshold
int px_vert
int px_hori
void (OptimizerFALM::* optimize_cost)(const Subset<double>&, Subset<double>&, const Interpolator&, const double, const double)