38 #define cimg_plugin "plugins/add_fileformat.h"
39 #define cimg_use_netcdf
41 #ifdef cimg_use_netcdf
42 #include "../NetCDF.Tool/struct_parameter_NetCDF.h"
45 #define cimg_plugin2 "plugins/netcdf_file_format4CImg2.h"
46 #define cimglist_plugin2 "plugins/netcdf_file_format4CImgList2.h"
47 #include "../CImg.Tool/CImg_NetCDF.h"
54 #include "Cmesh_factory.h"
56 #include "CshapeFunction_factory.h"
61 template<
typename T,
typename Timg>
67 std::string class_name;
68 std::vector<std::string> m_sequence;
69 std::vector<int> m_filter;
78 CImgList<T> m_modes, m_strain;
82 CImg<T> m_residues, m_deformed, m_correlograms;
84 std::vector<T> m_ref, m_meanRes;
92 class_name =
"Sequence : mother";
95 void init(
int argc,
char *argv[])
99 const char* paramPath;
100 paramPath = cimg_option(
"-p",
"./parameters.nc",
"parameter, mesh or true");
102 m_verbose = cimg_option(
"-v",
false,0);
106 printf(
"Mode Verbose\n");
107 printf(
"%s : %s\n",class_name.c_str(),paramPath);
110 NcFile file(paramPath,NcFile::ReadOnly);
111 CParameterNetCDF paramFile;
112 int error = paramFile.setFile(&file);
114 std::string var_name =
"sequence",
115 att_name =
"analysis";
116 error = paramFile.loadAttribute(att_name,m_sequence, &var_name);
117 if (this->m_verbose){std::cout<<
"\tSequence analysis -> [ ";
for (
int i=0; i<m_sequence.size(); i++){std::cout<<m_sequence[i]<<
" ";}std::cout<<
"]\n";}
120 error = paramFile.loadAttribute(att_name,m_filter, &var_name);
121 if (this->m_verbose){std::cout<<
"\tPiramidal filter -> [ ";
for (
int i=0; i<m_filter.size(); i++){std::cout<<m_filter[i]<<
" ";}std::cout<<
"]\n";}
137 for (
int s=0; s<m_sequence.size(); s++)
140 printf(
"\n----------------------\nSequence : %i\n----------------------\n\n", s);
142 preprocessing(argc, argv, s, oImage);
144 processing(argc, argv, oImage, *m_pMesh, *m_pField, *m_pCorrel);
155 void preprocessing(
int argc,
char *argv[],
const int &s,
Cimage<Timg> &oImage)
164 if (m_verbose){printf(
"* Mesh preproc\n");}
165 m_pMesh = mesh_factory.create(argc,argv);
167 if (m_verbose){printf(
"* Field preproc\n");}
168 m_pField = field_factory.
create(argc,argv);
170 if (m_verbose){printf(
"* Correlation preproc\n");}
171 m_pCorrel = correlator_factory.create(argc,argv);
173 if (m_verbose){cimg::tic();printf(
"* Image resizing for multiscale\n");}
174 oImage.
resize(m_filter[s]);
175 if (m_verbose){cimg::toc();}
177 printf(
"\n\n* Current scale : %f\n\n", std::pow(2,m_filter[s]));
187 if (m_verbose){printf(
"* Mesh proc\n");}
190 if (m_verbose){printf(
"* Field proc\n");}
191 oField.
exec(oImage, oMesh, m_modes, *m_pShape, m_ref, m_node);
195 if (oField.m_name.compare(0,2,
"IC") != 0)
197 m_pShape = shape_factory.create(argc,argv);
201 m_pShape = shape_factory.create(5);
204 if (m_verbose){cimg::tic();printf(
"* Correlation proc\n");}
205 oCorrel.exec(oImage,oMesh,oField);
206 if (m_verbose){cimg::toc();}
216 unsigned char color[] = {0};
219 (oField.m_mode).move_to(m_modes);
221 (oMesh.m_node).move_to(m_node);
227 m_ref = oField.m_ref;
235 if (s == m_sequence.size() - 1)
238 m_meanRes.push_back(oField.m_meanRes.back());
240 if (!oField.m_field.is_empty())
241 {(oField.m_field).move_to(m_fields);}
242 if (!oField.m_res.is_empty())
243 {(oField.m_res).move_to(m_residues);
if(!oImage.m_curMask.is_empty()){m_residues.mul(oImage.m_curMask);}}
244 if (!oField.m_def.is_empty())
245 {(oField.m_def).move_to(m_deformed);
if(!oImage.m_curMask.is_empty()){m_deformed.mul(oImage.m_curMask);}}
247 if (!m_fields.is_empty())
249 cimglist_for(m_fields, var)
251 if(!oImage.m_curMask.is_empty()){m_fields[var].mul(oImage.m_curMask);}
258 cimglist_for(m_node,dim){m_node[dim]*=oImage.m_pix[dim];}
This factory create a pointer toward the required ShapeFunction class. The pointer creation could onl...
Definition: CshapeFunction_factory.h:45
load image and mask from cdl and store fields. It also creates a resized version of data in the case ...
Definition: Csequence.h:62
void postprocessing(const int &s, Cimage< Timg > &oImage, Cfield< T, Timg > &oField, Ccorrelation< T, Timg > &oCorrel, Cmesh< T, Timg > &oMesh)
Definition: Csequence.h:212
Definition: Cmesh_factory.h:42
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
It returns a pointer toward a specific correlation method according to a parameter.nc file. The parameter file is set by default or could be provide by command line. create function could be called using : int, string = type, CParameterNetCDF, and finally [argv,argc] !!!! The function to get parameters directly from command line doesn't work yet.
Definition: Ccorrelation_factory.h:61
Cfield< T, Timg > * create(const int &number)
Definition: Cfield_factory.h:83
this is the mother class of every correlation classes. m_correl_type refers to the the type of correl...
Definition: Ccorrelation.h:65
void resize(const int &filter)
Definition: Cimage.h:178
CImg< T > m_correlogram
to improve, they shouldn't be here//
Definition: Cfield.h:74
It implements a vector of n pointer toward a specific Cpeak class to detected successive peaks within...
It returns a pointer toward a specific field container according to a parameter.nc file...
Definition: Cfield_factory.h:52