24 #ifndef CFIELD_OPTICALFLOW_FEM
25 #define CFIELD_OPTICALFLOW_FEM
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"
48 template<
typename T,
typename Timg>
58 this->class_name =
"Field : Optical Flow Finite Element Method";
66 this->m_mode.assign(oMesh.num_var(), oMesh.grid_dims(0),oMesh.grid_dims(1),oMesh.grid_dims(2), 1, 0);
76 if ((oShape_prev.m_name).compare(0,5,
"OFFEM") == 0)
79 Field2Field(modes_prev, modes_cur);
82 else if((oShape_prev.m_name).compare(0,2,
"IC") == 0)
86 CImgList<T> U(oMesh.num_var(), modes_prev[0].width(), modes_prev[0].height(), modes_prev[0].depth(), 1, 0);
88 {U[mode] = modes_prev[mode+2];}
90 Field2Field(U, modes_cur);
93 else if((oShape_prev.m_name).compare(0,4,
"OFIB") == 0)
97 CImgList<T> U(oMesh.num_var(), modes_prev[0].width(), modes_prev[0].height(), modes_prev[0].depth(), 1, 0);
98 OFIBU(oMesh, oImage, oShape_prev, ref_prev, nodes_prev, modes_prev, U);
100 Field2Field(U, modes_cur);
103 else if((oShape_prev.m_name).compare(0,3,
"OFI") == 0)
106 OFIU(oMesh, oImage, oShape_prev, ref_prev, nodes_prev, modes_prev, modes_cur);
109 else{printf(
"unknown name for previous correlation method");}
116 for (
int dim=0; dim<oMesh.num_var(); dim++)
118 if (ref_prev[dim] == -1)
120 ref_prev[dim] = (oImage.cur_dim(dim)*oImage.m_pix[dim])/2;
124 std::vector<T> X;X.assign(3,0);
125 CImgList<T> N(oMesh.num_var(), (oShape_prev).m_dof,1,1,1, 0);
127 cimglist_for(modes_cur, dim)
129 cimglist_for(modes_prev, mode)
131 cimg_forXYZ(oMesh.m_node[dim],x,y,z)
134 X[0] = oMesh.m_node(0, x,y,z)*oImage.m_pix[0] - ref_prev[0];
135 X[1] = oMesh.m_node(1, x,y,z)*oImage.m_pix[1] - ref_prev[1];
136 if (this->_3D){X[2] = oMesh.m_node(2, x,y,z)*oImage.m_pix[2] - ref_prev[2];}
138 oShape_prev.exec(modes_cur[dim], X, N);
139 modes_cur(dim, x,y,z) += modes_prev[mode][0]*N[dim][mode];
149 std::vector<T> X; X.assign(3,0);
150 CImgList<T> N(oMesh.num_var(), (oShape_prev).m_dof,1,1,1, 0);
154 cimglist_for(modes_prev, mode)
156 cimg_forXYZ(nodes_prev[0],x,y,z)
159 if (ref_prev[0] != -1){X[0] = nodes_prev(0,x,y,z) - ref_prev[0];}
160 if (ref_prev[1] != -1){X[1] = nodes_prev(1,x,y,z) - ref_prev[1];}
161 if (ref_prev[2] != -1 and nodes_prev.size()==3){X[2] = nodes_prev(2,x,y,z) - ref_prev[2];}
163 oShape_prev.exec(U[dim], X, N);
164 U(dim, x,y,z) += modes_prev(mode, x,y,z)*N[dim][mode];
171 void Field2Field(
const CImgList<T> &U, CImgList<T> &modes_cur)
174 cimglist_for(modes_cur, mode)
176 modes_cur[mode] = U[mode].get_resize(this->grid_dims(0),this->grid_dims(1),this->grid_dims(2),this->grid_dims(3),3);
this class implement the initialization of fields, residue map and deformed image from data coming fr...
Definition: Cfield_opticalFlow.h:50
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 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
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_fem.h:62
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_fem.h:73
Cfield_opticalFlow_fem()
Definition: Cfield_opticalFlow_fem.h:55