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