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
CNpeak.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 CNPEAK
25 #define CNPEAK
26 
27 
28 
38 //-----------------------------CIMG_NETCDF-------------------------------
39 #define cimg_plugin "plugins/add_fileformat.h"
40 #define cimg_use_netcdf
41 
42 #ifdef cimg_use_netcdf
43  #include "../NetCDF.Tool/struct_parameter_NetCDF.h"
44 // #define cimg_plugin1 "plugins/netcdf_file_format4CImg1.h"
45 // #define cimglist_plugin1 "plugins/netcdf_file_format4CImgList1.h"
46  #define cimg_plugin2 "plugins/netcdf_file_format4CImg2.h"
47  #define cimglist_plugin2 "plugins/netcdf_file_format4CImgList2.h"
48  #include "../CImg.Tool/CImg_NetCDF.h"
49 #endif
50 //-----------------------------CIMG_NETCDF-------------------------------
51 
52 #include "Cpeak_factory.h"
53 #include "CImg_math.h"
54 
55 template<typename T> class CNpeak
56 {
57 
58  public:
59 
60  std::string class_name;
61  std::vector<Cpeak<T>*> m_Npeak;//attribute : vector of Cpeak object pointer
62  CImgList<T> m_Nstat;// [flag,snr,x,y,z](0,0,0,peaks)
63  float m_snr;// Signal Noise Ratio
64  int m_nbPeak, m_dim; //number of peak required, spatial dimensions
65 
66  bool m_verbose;
67 
68 
69  CNpeak(std::string &type, const int &number=3, const int &dim=2)
70  {// constructor
71 
72  class_name = "CNpeak";
73 
74  m_nbPeak = number;//number of peak to detect
75  m_dim = dim;// spatial dimensions
76  m_snr = 0;// init of Signal Noise Ratio
77 
78  init(type);
79 
80  }
81 
82  ~CNpeak()
83  {// destructor
84 
85  for (int i=0; i< m_Npeak.size(); i++)
86  {
87  delete m_Npeak[i];
88  };
89 
90  }
91 
92  void init(std::string &type)
93  {// init
94 
95  m_Npeak.clear();
96 
97  for (int i=0; i<=m_nbPeak; i++)
98  {//m_nbPeak + 1 for SNR calcul
101  Cpeak_factory<T> peak_factory("peak");
102  Cpeak<T>* pPeak=peak_factory.create(type);
103  pPeak->m_verbose = m_verbose;
104  m_Npeak.push_back(pPeak);
105  }
106 
107  m_Nstat.assign(m_dim+2,1,1,1,m_nbPeak+1,0); //[flag,snr,x,y,z](0,0,0,peaks)
108 
109  }
110 
111 
112 
113  void store(const int &i, const int &j)
114  {// store peak stats
115  m_Nstat(j,0,0,0,i) = (*m_Npeak[i]).content()[j];
116  }
117 
118  void exec(CImg<T> &img)
119  {// exec
120 
124  for (int i=0; i<m_Npeak.size(); i++)
125  {// ieme execution of Cpeak->exec() method
126 
127  m_Npeak[i]->exec(img);
128 
129  for (int j=0; j<m_Nstat.size(); j++)
130  {// store results
131  store(i,j);
132  }
133 
134  }
135 
136  snr(m_Nstat);
137 
138  }
139 
140  void snr(CImgList<T> snRatio)
141  {
142 
143  for (int i=0; i<m_nbPeak; i++)
144  {// Signal Noise Ratio calcul -> 1 - peak_i/peak_i+1 (0 = poor snr, <<0 = good snr)
145  snRatio(1,0,0,0,i) = snRatio(1,0,0,0,i+1)*100/snRatio(1,0,0,0,i);
146  }
147 
148  }
149 
150 
151 };
152 
153 #endif
Definition: CNpeak.h:55
void init(std::string &type)
Definition: CNpeak.h:92
This class localizes the most important peak within an image, removes it and provide peak statistics...
Definition: Cpeak.h:47
Definition: Cpeak_factory.h:46
void exec(CImg< T > &img)
Definition: CNpeak.h:118