24 #ifndef CFIELD_OPTICALFLOW_INTEGRATED
25 #define CFIELD_OPTICALFLOW_INTEGRATED
29 #define cimg_plugin "plugins/add_fileformat.h"
30 #define cimg_use_netcdf
32 #ifdef cimg_use_netcdf
33 #include "../NetCDF.Tool/struct_parameter_NetCDF.h"
36 #define cimg_plugin2 "plugins/netcdf_file_format4CImg2.h"
37 #define cimglist_plugin2 "plugins/netcdf_file_format4CImgList2.h"
38 #include "../CImg.Tool/CImg_NetCDF.h"
42 #include "Cfield_opticalFlow.h"
49 template<
typename T,
typename Timg>
59 this->class_name =
"Field : Optical Flow Integrated";
63 virtual void init(CParameterNetCDF &fp)
68 this->m_ref.assign(3,-1);
70 std::string attribute_name(
"refX");
71 int error = fp.loadAttribute(attribute_name,this->m_ref[0]);
72 attribute_name =
"refY";
73 error = fp.loadAttribute(attribute_name,this->m_ref[1]);
74 attribute_name =
"refZ";
75 error = fp.loadAttribute(attribute_name,this->m_ref[2]);
77 if (this->m_verbose){printf(
"\tReference system : [%f,%f,%f]\n", this->m_ref[0], this->m_ref[1], this->m_ref[2]);}
86 this->m_mode.assign(this->m_pShape->m_dof, 1,1,1,1, 0);
96 if ((oShape_prev.m_name).compare(0,5,
"OFFEM") == 0)
100 Field2Mod(oImage, oMesh, nodes_prev, modes_prev, modes_cur);
103 else if((oShape_prev.m_name).compare(0,2,
"IC") == 0)
107 CImgList<T> U(oMesh.num_var(), modes_prev[0].width(), modes_prev[0].height(), modes_prev[0].depth(), 1, 0);
108 cimglist_for(U, mode)
109 {U[mode] = modes_prev[mode+2];}
112 Field2Mod(oImage, oMesh, nodes_prev, U, modes_cur);
115 else if((oShape_prev.m_name).compare(0,4,
"OFIB") == 0)
120 CImgList<T> U(oMesh.num_var(), modes_prev[0].width(), modes_prev[0].height(), modes_prev[0].depth(), 1, 0);
121 this->OFIBU(oMesh, oImage, oShape_prev, ref_prev, nodes_prev, modes_prev, U);
124 Field2Mod(oImage, oMesh, nodes_prev, U, modes_cur);
127 else if((oShape_prev.m_name).compare(0,3,
"OFI") == 0)
130 if (modes_cur.size() == modes_prev.size())
131 {modes_cur = modes_prev;}
133 {printf(
"warning : modes have been changes for multi-scale OFI strategy!!!");}
136 else{printf(
"unknown name for previous correlation method");}
146 for (
int dim=0; dim<oMesh.num_var(); dim++)
150 ref[dim] = (oImage.cur_dim(dim)*oImage.m_pix[dim])/2;
154 ref[dim] = ref[dim]*oImage.m_Rpxmm;
174 std::vector<T> X;X.assign(3,0);
175 CImgList<T> N(oMesh.num_var(), Ti.size());
176 CImg<T> K(Ti.size(), Ti.size(),1,1,0), F(1,Ti.size(),1,1,0);
178 cimglist_for(oMesh.m_connect, elem)
181 e_ref(oImage, oMesh, elem, this->m_ref);
189 cimg_forXYZ(nodes_prev[dim],x,y,z)
193 X[0] = nodes_prev(0, x,y,z) - this->m_ref[0];
194 X[1] = nodes_prev(1, x,y,z) - this->m_ref[1];
195 if(nodes_prev.size() == 3){X[2] = nodes_prev(2, x,y,z) - this->m_ref[2];}
198 this->m_pShape->exec(U[dim],X, N);
200 K += matrixProduct(N[dim].get_transpose(),N[dim]);
201 F += (N[dim].get_transpose())*U(dim, x,y,z);
In this class, specific projection field method is implemented. In the case of F.E.M. the node value is equal to the field at node position, so "fromField2Mod" simply implements a parallelized loop over elements and extracts from previous fields the node value at node location.
Definition: Cfield_opticalFlow_fem.h:49
virtual void Field2Mod(const Cimage< Timg > &oImage, const Cmesh< T, Timg > &oMesh, const CImgList< T > &nodes_prev, const CImgList< T > &U, CImgList< T > &Ti)
Definition: Cfield_opticalFlow_integrated.h:160
virtual void exec(const Cimage< Timg > &oImage, const Cmesh< T, Timg > &oMesh, CImgList< T > &modes_prev, CshapeFunction< T, Timg > &oShape_prev, const std::vector< T > &ref_prev, const CImgList< T > &nodes_prev)
Definition: Cfield.h:100
This is the mother class of shape function objets (virtual pure).
Definition: CshapeFunction.h:48
In this class, specific projection field method is implemented. In the case of O.F.F.E.M. the node value must be identified through a projection, so "fromField2Mod" implements a parallelized loop over image pixel and identifies modes from a least square method strategy.
Definition: Cfield_opticalFlow_integrated.h:50
virtual void init(CParameterNetCDF &fp)
Definition: Cfield_opticalFlow.h:62
virtual void exec(const Cimage< Timg > &oImage, const Cmesh< T, Timg > &oMesh, CImgList< T > &modes_prev, CshapeFunction< T, Timg > &oShape_prev, const std::vector< T > &ref_prev, const CImgList< T > &nodes_prev)
Definition: Cfield_opticalFlow_integrated.h:82
virtual void init(CParameterNetCDF &fp)
Definition: Cfield_opticalFlow_integrated.h:63
virtual void project(const Cmesh< T, Timg > &oMesh, const Cimage< Timg > &oImage, CImgList< T > &modes_prev, CshapeFunction< T, Timg > &oShape_prev, const std::vector< T > &ref_prev, const CImgList< T > &nodes_prev, CImgList< T > &modes_cur)
Definition: Cfield_opticalFlow_integrated.h:93
Cfield_opticalFlow_integrated()
Definition: Cfield_opticalFlow_integrated.h:56