YaDICs  V04.14.a
Yet another Digital Image Correlation software: platform dedicated to 2/3D Fluid and Solid kinematics field measurements.
 All Classes Files Functions Variables Pages
CshapeFunction_global_image.h
Go to the documentation of this file.
1 /**********************************************************************
2  * Copyright (C) 2012, The YaDICs Project Developers.
3  * See the COPYRIGHT file at the top-level directory of this distribution ./COPYRIGHT.
4  * See ./COPYING file for copying and redistribution conditions.
5  *
6  * This file is part of YaDICs.
7  * YaDICs is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * YaDICs is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with YaDICs. If not, see <http://www.gnu.org/licenses/>.
19  *
20  * Information about how to use the software are provided at http://yadic.univ-lille1.fr/
21  **********************************************************************/
22 
23 
24 #ifndef CSHAPEFUNCTION_GLOBAL_IMAGE
25 #define CSHAPEFUNCTION_GLOBAL_IMAGE
26 
35 
39 template<typename T,typename Timg>
41 {
42 
43  public:
44 
45  std::vector<int> m_modImg;//name set of required modes
46  CImgList<T> m_img;//images list of modes m_img[list][x,y,z,dimensions]
47  CImg<char> m_img_path;
48  int m_dim_space, m_dim_mode;
49 
51  {// constructor
52 
53  this->class_name = "CshapeFunction_global_image";
54 
55  }
56 
57  virtual void init(CParameterNetCDF &fp)
58  {//fill m_mods vector with the name of required modes from parameter.nc
59 
60  //look for the Rigid Body set of required modes.
62 
63  //identify the Homogeneous Deformation modes withins this->m_mods[] and store them within m_modHD[]
64  m_modImg.clear();
65  for (int i=0; i<this->m_mods.size(); i++)
66  {
67 
68  if (this->m_mods[i].compare(0,8,"mode_img") == 0)
69  {//mode list of images
70 
71  //load the image and mask directory path
73  m_img_path.var_name = "mode_img";
75  m_img_path.load(this->m_paramPath);
77  m_dim_mode = m_img_path.depth();
79  m_dim_space = m_img_path.height();
80 
81 
83  std::string name;
84  std::ostringstream sample_index;
85  this->m_mods.pop_back();
86 
87  for (int j=0; j<m_dim_mode; j++)
88  {
89  m_modImg.push_back(i+j);
90 
91  sample_index.width(2);
92  sample_index.fill('0');
93  sample_index << j;
94  name = "Mimg_" + sample_index.str();
95  this->m_mods.push_back(name);
96  sample_index.str("");
97 
98  }
99  this->m_dof = this->m_mods.size();
100 
101  if (this->m_verbose)
102  {
103  std::cout<<"\tmodes actualized : [ ";for (int i=0; i<this->m_mods.size(); i++){std::cout<<this->m_mods[i]<<" ";}std::cout<<"]\n";
104  std::cout<<"\tmodes IMG : [ ";for (int i=0; i<m_modImg.size(); i++){std::cout<<m_modImg[i]<<" ";}std::cout<<"]\n";
105  }
106 
107  CImg<T> tmp;
109  tmp.load((std::string(m_img_path.get_shared_row(0,0))).c_str());
110 
111  m_img.assign(this->m_dim_mode, tmp.width(), tmp.height(), tmp.depth(), this->m_dim_space);
112 
113  cimglist_for(this->m_img,md)
114  {// for image ref and def and eventually more
115 
116  for (int dim=0; dim<m_dim_space; dim++)
117  {
118 
119  if (this->m_verbose){std::cout<<(std::string(m_img_path.get_shared_row(dim,md))).c_str()<<"\n";}
120 
121  tmp.load((std::string(m_img_path.get_shared_row(dim,md))).c_str());
122 
123  cimg_forXYZ(tmp, x,y,z)
124  {
125  m_img(md,x,y,z,dim) = tmp(x,y,z);
126  }
127 
128  }
129 
130  }
131 
132  }
133 
134  }
135 
136  }
137 
138  virtual void exec(const CImg<Timg> &box, const std::vector<T> &x, CImgList<T> &N)
139  {
140 
141  //RigidBody modes
143 
144  /* \todo warning ref = 0 doesn't works*/
145  std::vector<double> X;
146  X.assign(3,0);
147  X[0] = (double)(x[0]+box.width()/2.)/((double)box.width()/(double)m_img[0].width());
148  X[1] = (double)(x[1]+box.height()/2.)/((double)box.height()/(double)m_img[0].height());
149  X[2] = (double)(x[2]+box.depth()/2)/((double)box.depth()/(double)m_img[0].depth());
150 
151 // std::cout<<x[0]<<" : "<<x[1]<<" : "<<x[2]<<"\n";
152 // std::cout<<box.width()<<" : "<<box.height()<<" : "<<box.depth()<<"\n";
153 // std::cout<<m_img[0].width()<<" : "<<m_img[0].height()<<" : "<<m_img[0].depth()<<"\n";
154 // std::cout<<X[0]<<" : "<<X[1]<<" : "<<X[2]<<"\n\n\n";
155 //
156  cimglist_for(m_img, mode)
157  {
158  cimg_forC(m_img[0], dim)
159  {
160  N[dim][m_modImg[mode]] = m_img[mode].linear_atXYZC(X[0],X[1],X[2],dim);
161  }
162  }
163 
164  }
165 
166 };
167 
168 #endif
Definition: CshapeFunction_global_image.h:40
This class implements Rigid Body shape functions available for 2D and 3D cases. It implements 3 rigid...
Definition: CshapeFunction_global_rigidBody.h:41
virtual void init(CParameterNetCDF &fp)
Definition: CshapeFunction_global_rigidBody.h:56
virtual void init(CParameterNetCDF &fp)
Definition: CshapeFunction_global_image.h:57