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
Cformat_double_double.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 CFORMAT_DOUBLE_DOUBLE
25 #define CFORMAT_DOUBLE_DOUBLE
26 
35 #include "Cformat.h"
36 
38 {
39 
40  public:
41 
43  {// constructor
44 
45  this->class_name = "Format : double double";
46 
47  }
48 
49  virtual void exec(int argc, char *argv[])
50  {
51 
52  //output name
53  std::string ofile = cimg_option("-o","./","ofile");
54 
55  //create image container object
56  Cimage_factory<double> image_factory("image_list");
57  Cimage<double>* pImage = image_factory.create(argc,argv);
58 
59  //create sequence correlation object
61  pSequence->init(argc, argv);
62 
63  for (int s=0; s<pImage->num_samples(); s++)
64  {
65 
66  frame_number = s;
67 
68  pImage->exec(argc, argv, s);//load images
69 
70  //Test if the image sequence is (A-B, B-C...) or (A-B, C-D...) as in PIV. In the last case, pSequence->m_dataField must be clear. Otherwise, the second correlation sequence will be treated with the previous field as init.
71  if (pImage->m_mode != DEPENDENT){pSequence->m_modes.clear();}
72  pSequence->exec(argc, argv, *pImage);//perform correlation sequences
73 
74  this->save(*pSequence, *pImage, ofile, frame_number);
75 
76  }//end image list
77 
78  CImg<T> res(pSequence->m_meanRes.size(),1,1,1,0);
79  cimg_forX(res,step){res[step] = pSequence->m_meanRes[step];}
80  pImage->save_netcdf(res, ofile + "residue_mean", 0);
81 
82  std::cout<<"calcul done\n";
83 
84  delete pImage;
85  delete pSequence;
86 
87  }
88 
89  void save(Csequence<double,double> &oSequence, Cimage<double> &oImage, const std::string &ofile, int &s)
90  {
91 
92  std::cout<<"-------------------------------\n";
93  std::cout<<"\n\nData saving\n\n";
94  std::cout<<"-------------------------------\n";
95 
96 
97  std::string sample_string;
98  std::ostringstream sample_index;
99 
100  oImage.save_netcdf(oSequence.m_modes, ofile + "modes", s);
101 
103  if (!oSequence.m_correlograms.is_empty())
104  {
105  if (oImage.m_oFormat!="tiff")
106  {
107  oImage.save_netcdf(oSequence.m_correlograms, ofile + "correlograms", s);
108  }
109  else
110  {
111  sample_index.width(5);
112  sample_index.fill('0');
113  sample_index << s;
114 
115  sample_string = ofile + "correlograms_"+sample_index.str()+".tiff";
116  oSequence.m_correlograms.save_tiff(sample_string.c_str());
117 
118  sample_index.str("");
119 
120  }
121 
122  }
123 
124  if (!oSequence.m_residues.is_empty())
125  {
126  if (oImage.m_oFormat!="tiff")
127  {
128  oImage.save_netcdf(oSequence.m_residues, ofile + "residue", s);
129  }
130  else
131  {
132 
133  sample_index.width(5);
134  sample_index.fill('0');
135  sample_index << s;
136 
137  sample_string = ofile + "residue_"+sample_index.str()+".tiff";
138 
139  oSequence.m_residues.save_tiff(sample_string.c_str());
140 
141  sample_index.str("");
142 
143  }
144  }
145 
146  if (!oSequence.m_deformed.is_empty())
147  {
148  if (oImage.m_oFormat!="tiff")
149  {
150  oImage.save_netcdf(oSequence.m_deformed, ofile + "deform", s);
151  }
152  else
153  {
154  sample_index.width(5);
155  sample_index.fill('0');
156  sample_index << s;
157 
158  sample_string = ofile + "deform_"+sample_index.str()+".tiff";
159 
160  oSequence.m_deformed.save_tiff(sample_string.c_str());
161 
162  sample_index.str("");
163  }
164  }
165 
166  if (!oSequence.m_fields.is_empty())
167  {
168  if (oImage.m_oFormat!="tiff")
169  {
170  oImage.save_netcdf(oSequence.m_fields, ofile + "fields", s);
171  }
172  else
173  {
174  cimglist_for(oSequence.m_fields, l)
175  {
176 
177  sample_index.width(5);
178  sample_index.fill('0');
179  sample_index << s;
180 
181  if(l == 0){sample_string = ofile + "U_"+sample_index.str()+".tiff";}
182  if(l == 1){sample_string = ofile + "V_"+sample_index.str()+".tiff";}
183  if(l == 2){sample_string = ofile + "W_"+sample_index.str()+".tiff";}
184 
185  oSequence.m_fields[l].save_tiff(sample_string.c_str());
186 
187  sample_index.str("");
188 
189  }
190 
191  }
192 
193  }
194 
195  if (!oSequence.m_node.is_empty() and s == 0)
196  {
197  if (oImage.m_oFormat!="tiff")
198  {
199  oImage.save_netcdf(oSequence.m_node, ofile + "nodes", s);
200  }
201  else
202  {
203  cimglist_for(oSequence.m_node, l)
204  {
205 
206  if(l == 0){sample_string = ofile + "X.tiff";}
207  if(l == 1){sample_string = ofile + "Y.tiff";}
208  if(l == 2){sample_string = ofile + "Z.tiff";}
209 
210  oSequence.m_node[l].save_tiff(sample_string.c_str());
211 
212  }
213 
214  }
215  }
216 
217  if (!oImage.m_mask.is_empty() and s == 0)
218  {
219 
220  CImg<int> msk(oImage.m_mask.get_resize(oSequence.m_node[0],1));
221 
222  if (oImage.m_oFormat!="tiff")
223  {
224  oImage.save_netcdf(msk, ofile + "mask_modes", s);
225  }
226  else
227  {
228  sample_string = ofile + "mask_modes_"+".tiff";
229  msk.save_tiff(sample_string.c_str());
230  }
231 
232  }
233 
234  }
235 
236 
237 };
238 
239 #endif
240 
void save(Csequence< double, double > &oSequence, Cimage< double > &oImage, const std::string &ofile, int &s)
Definition: Cformat_double_double.h:89
Definition: Csequence.h:62
void save_netcdf(CImgList< T > &img, std::string name="images", const int &sample=0) const
Definition: Cimage.h:295
Definition: Cformat_double_double.h:37
Definition: Cimage.h:57
Definition: Cformat.h:52
It returns a pointer toward a specific Image loader class 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: Cimage_factory.h:61