dicoptimizer.hpp¶
-
namespace optimizer¶
Functions
-
void init(std::string &corr_crit, std::string &shape_func)¶
Initializes the optimizer with the correlation criteria and shape function. Calls setCostFunction and setShapeFunction.
- Parameters:
corr_crit – [in] string for the correlation criteria, e.g. “SSD”, “NSSD”, “ZNSSD”.
shape_func – [in] string for the shape function, e.g. “AFFINE”, “RIGID”.
-
void setCostFunction(const std::string &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] string for the correlation criteria, e.g. “SSD”, “NSSD”, “ZNSSD”.
-
void setShapeFunction(const std::string &shape_func)¶
This function gets called before the corrolation optimization starts. Sets the function pointer for the user specified shape function.
- Parameters:
shape_func – [in] string for the shape function, e.g. “AFFINE”, “RIGID”.
-
void debugPrint(int ss_x, int ss_y, int iter, double costp, double ftol, double xtol, const std::vector<double> &p)¶
- Parameters:
ss_x –
ss_y –
iter –
costp –
ftol –
xtol –
p –
-
util::Results solve(const double ss_x, const double ss_y, util::Subset &ss_ref, util::Subset &ss_def, const Interpolator &interp_ref, optimizer::Parameters &opt, const std::string &corr_crit)¶
- Parameters:
ss_x –
ss_y –
ss_ref –
ss_def –
interp_ref –
opt –
- Returns:
-
void ssd(const util::Subset &ss_ref, util::Subset &ss_def, const Interpolator &interp_def, optimizer::Parameters &opt)¶
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
opt – [inout] Optimization parameters including gradient, Hessian, etc.
-
void nssd(const util::Subset &ss_ref, util::Subset &ss_def, const Interpolator &interp_def, optimizer::Parameters &opt)¶
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
opt – [inout] Optimization parameters including gradient, Hessian, etc.
-
void znssd(const util::Subset &ss_ref, util::Subset &ss_def, const Interpolator &interp_def, optimizer::Parameters &opt)¶
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
opt – [inout] Optimization parameters including gradient, Hessian, etc.
-
bool invertMatrix(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, …)
-
inline void affine(double &x_new, double &y_new, double x, double y, std::vector<double> &p)¶
- Parameters:
x_new – [out]
y_new – [out]
x – [in]
y – [in]
p – [in]
-
inline void rigid(double &x_new, double &y_new, double x, double y, std::vector<double> &p)¶
- Parameters:
x_new – [out]
y_new – [out]
x – [in]
y – [in]
p – [in]
-
inline void quad(double &x_new, double &y_new, double x, double y, std::vector<double> &p)¶
- Parameters:
x_new – [out]
y_new – [out]
x – [in]
y – [in]
p – [in]
-
inline void daffine_dp(std::vector<double> &dfdp, double x, double y, double dfdx, double dfdy)¶
calculates the derivative of the affine function with respect to each parameter
- Parameters:
[out – dfdp
x – [in]
y – [in]
dfdx – [in]
dfdy – [in]
-
inline void drigid_dp(std::vector<double> &dfdp, double x, double y, double dfdx, double dfdy)¶
calculates the derivative of the rigid shape function with respect to each parameter
- Parameters:
[out – dfdp
x – [in]
y – [in]
dfdx – [in]
dfdy – [in]
-
inline void dquad_dp(double &x_new, double &y_new, double x, double y, std::vector<double> &p)¶
calculates the derivative of the quadratic function with respect to each parameter
- Parameters:
x_new – [out]
y_new – [out]
x – [in]
y – [in]
p – [in]
-
void affine_parameters_to_displacement(util::Results &results, double ss_x, double ss_y, std::vector<double> &p)¶
Funcion to convert affine shape function parameters to displacement values.
- Parameters:
displacements – [out] values (u,v, magnitude) are added to results
ss_x – [in] subset x coordinate
ss_y – [in] subset y coordinate
p – [in] shape function parameters
-
void rigid_parameters_to_displacement(util::Results &results, double ss_x, double ss_y, std::vector<double> &p)¶
Funcion to convert affine shape function parameters to displacement values.
- Parameters:
displacements – [out] values (u,v, magnitude) are added to results
ss_x – [in] subset x coordinate
ss_y – [in] subset y coordinate
p – [in] shape function parameters
-
struct Parameters¶
Public Functions
-
inline Parameters(int num_params_, int max_iter_, double precision_, double opt_threshold_, int px_vert_, int px_hori_)¶
Public Members
-
int num_params¶
-
double lambda¶
-
double costp¶
-
double costpdp¶
-
std::vector<double> g¶
-
std::vector<double> dfdp¶
-
std::vector<double> H¶
-
std::vector<double> invH¶
-
std::vector<double> p¶
-
std::vector<double> dp¶
-
std::vector<double> pdp¶
-
std::vector<double> augmented¶
-
int max_iter¶
-
double precision¶
-
double opt_threshold¶
-
int px_vert¶
-
int px_hori¶
-
inline Parameters(int num_params_, int max_iter_, double precision_, double opt_threshold_, int px_vert_, int px_hori_)¶
-
void init(std::string &corr_crit, std::string &shape_func)¶