You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
157 lines
4.5 KiB
157 lines
4.5 KiB
3 months ago
|
|
||
|
|
||
|
#pragma once
|
||
|
|
||
|
#ifndef _ICGN_H_
|
||
|
#define _ICGN_H_
|
||
|
|
||
|
#include "oc_cubic_bspline.h"
|
||
|
#include "oc_dic.h"
|
||
|
#include "oc_gradient.h"
|
||
|
#include "oc_image.h"
|
||
|
#include "oc_interpolation.h"
|
||
|
#include "oc_poi.h"
|
||
|
#include "oc_point.h"
|
||
|
#include "oc_subset.h"
|
||
|
|
||
|
namespace opencorr
|
||
|
{
|
||
|
|
||
|
class ICGN2D1_
|
||
|
{
|
||
|
public:
|
||
|
Subset2D* ref_subset;
|
||
|
Subset2D* tar_subset;
|
||
|
Eigen::MatrixXf error_img;
|
||
|
Matrix6f hessian, inv_hessian;
|
||
|
float*** sd_img; //steepest descent image
|
||
|
|
||
|
static ICGN2D1_* allocate(int subset_radius_x, int subset_radius_y);
|
||
|
static void release(ICGN2D1_* instance);
|
||
|
static void update(ICGN2D1_* instance, int subset_radius_x, int subset_radius_y);
|
||
|
};
|
||
|
|
||
|
class ICGN2D1 : public DIC
|
||
|
{
|
||
|
private:
|
||
|
Interpolation2D* tar_interp; //interpolation for generating target subset during iteration
|
||
|
Gradient2D4* ref_gradient; //gradient for calculating Hessian matrix of reference subset
|
||
|
|
||
|
float conv_criterion; //convergence criterion: norm of maximum deformation increment in subset
|
||
|
float stop_condition; //stop condition: max iteration
|
||
|
|
||
|
std::vector<ICGN2D1_*> instance_pool; //pool of instances for multi-thread processing
|
||
|
ICGN2D1_* getInstance(int tid); //get an instance according to the number of current thread id
|
||
|
|
||
|
public:
|
||
|
ICGN2D1(int subset_radius_x, int subset_radius_y, float conv_criterion, float stop_condition, int thread_number);
|
||
|
~ICGN2D1();
|
||
|
|
||
|
void prepareRef(); //calculate gradient maps of ref image
|
||
|
void prepareTar(); //calculate interpolation coefficient look_up table of tar image
|
||
|
void prepare(); //calculate gradient maps of ref image and interpolation coefficient look_up table of tar image
|
||
|
|
||
|
void compute(POI2D* poi);
|
||
|
void compute(std::vector<POI2D>& poi_queue);
|
||
|
|
||
|
void setIteration(float conv_criterion, float stop_condition);
|
||
|
void setIteration(POI2D* poi);
|
||
|
};
|
||
|
|
||
|
|
||
|
|
||
|
//this part of module is the implementation of
|
||
|
//Y. Gao et al, Optics and Lasers in Engineering (2015) 65: 73-80.
|
||
|
//https://doi.org/10.1016/j.optlaseng.2014.05.013
|
||
|
|
||
|
class ICGN2D2_
|
||
|
{
|
||
|
public:
|
||
|
Subset2D* ref_subset;
|
||
|
Subset2D* tar_subset;
|
||
|
Eigen::MatrixXf error_img;
|
||
|
Matrix12f hessian, inv_hessian;
|
||
|
float*** sd_img;
|
||
|
|
||
|
static ICGN2D2_* allocate(int subset_radius_x, int subset_radius_y);
|
||
|
static void release(ICGN2D2_* instance);
|
||
|
static void update(ICGN2D2_* instance, int subset_radius_x, int subset_radius_y);
|
||
|
};
|
||
|
|
||
|
class ICGN2D2 : public DIC
|
||
|
{
|
||
|
private:
|
||
|
Interpolation2D* tar_interp;
|
||
|
Gradient2D4* ref_gradient;
|
||
|
|
||
|
float conv_criterion;
|
||
|
float stop_condition;
|
||
|
|
||
|
std::vector<ICGN2D2_*> instance_pool;
|
||
|
ICGN2D2_* getInstance(int tid);
|
||
|
|
||
|
public:
|
||
|
ICGN2D2(int subset_radius_x, int subset_radius_y, float conv_criterion, float stop_condition, int thread_number);
|
||
|
~ICGN2D2();
|
||
|
|
||
|
void prepareRef();
|
||
|
void prepareTar();
|
||
|
void prepare();
|
||
|
|
||
|
void compute(POI2D* poi);
|
||
|
void compute(std::vector<POI2D>& poi_queue);
|
||
|
|
||
|
void setIteration(float conv_criterion, float stop_condition);
|
||
|
void setIteration(POI2D* poi);
|
||
|
};
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
class ICGN3D1_
|
||
|
{
|
||
|
public:
|
||
|
Subset3D* ref_subset;
|
||
|
Subset3D* tar_subset;
|
||
|
float*** error_img;
|
||
|
Matrix12f hessian, inv_hessian;
|
||
|
float**** sd_img; //steepest descent image
|
||
|
|
||
|
static ICGN3D1_* allocate(int subset_radius_x, int subset_radius_y, int subset_radius_z);
|
||
|
static void release(ICGN3D1_* instance);
|
||
|
static void update(ICGN3D1_* instance, int subset_radius_x, int subset_radius_y, int subset_radius_z);
|
||
|
};
|
||
|
|
||
|
class ICGN3D1 : public DVC
|
||
|
{
|
||
|
private:
|
||
|
Interpolation3D* tar_interp; //interpolation for generating target subset during iteration
|
||
|
Gradient3D4* ref_gradient; //gradient for calculating Hessian matrix of reference subset
|
||
|
|
||
|
float conv_criterion; //convergence criterion: norm of maximum displacement increment in subset
|
||
|
float stop_condition; //stop condition: max iteration
|
||
|
|
||
|
std::vector<ICGN3D1_*> instance_pool; //pool of instances for multi-thread processing
|
||
|
ICGN3D1_* getInstance(int tid); //get an instance according to the number of current thread id
|
||
|
|
||
|
public:
|
||
|
ICGN3D1(int subset_radius_x, int subset_radius_y, int subset_radius_z,
|
||
|
float conv_criterion, float stop_condition, int thread_number);
|
||
|
~ICGN3D1();
|
||
|
|
||
|
void prepareRef(); //calculate gradient matrices of ref image
|
||
|
void prepareTar(); //calculate interpolation coefficient matrix of tar image
|
||
|
void prepare(); //calculate gradient matrices of ref image and interpolation coefficient matrix of tar image
|
||
|
|
||
|
void compute(POI3D* poi);
|
||
|
void compute(std::vector<POI3D>& poi_queue);
|
||
|
|
||
|
void setIteration(float conv_criterion, float stop_condition);
|
||
|
void setIteration(POI3D* poi);
|
||
|
};
|
||
|
|
||
|
}//namespace opencorr
|
||
|
|
||
|
#endif //_ICGN_H_
|