A.I.M.S algorithms


finiteElementSmoother_d.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 
35 #ifndef AIMS_PRIMALSKETCH_FINITEELEMENTSMOOTHER_D_H
36 #define AIMS_PRIMALSKETCH_FINITEELEMENTSMOOTHER_D_H
37 
38 #include <cstdlib>
40 #include <aims/mesh/curv.h>
42 #include <stdlib.h>
43 #include <math.h>
44 #include <float.h>
45 
46 namespace aims {
47 
48 template<int D, typename T> Texture<T> FiniteElementSmoother<D,T>::doSmoothing(const Texture<T> & ima, int maxiter, bool verbose)
49 {
50  Texture<T> textOut;
51  TimeTexture<T> textIn, textTmp1;
52  TimeTexture<float> textTmp2;
53  Texture<float> smooth, lapl;
54  float s;
55  unsigned i,n=ima.nItem();
56  int iter;
57  //float threshold=0.1;
58 
60  textIn[0]=ima;
61 
62  if (maxiter >= 0)
63  {
64  conv.convert(textIn, textTmp2);
65  smooth=textTmp2[0];
66  if (verbose) std::cout << "Starting smoothing in " << maxiter << " iterations" << std::endl;
67  for (iter=0; iter< maxiter; ++iter)
68  {
69  lapl = AimsMeshLaplacian(smooth, weightLapl);
70  //lapl = AimsMeshLaplacian(smooth, weightLapl, threshold);
71  //lapl = AimsMeshLaplacian(smooth, weightLapl, FLT_MAX);
72  for ( i=0; i<n; ++i)
73  {
74  s = smooth.item(i) + _dt * lapl.item(i);
75  smooth.item(i) = s;
76  }
77  }
78  if (verbose) std::cout << std::endl;
79 
80  textTmp2[0]=smooth;
81 
83  conv2.convert( textTmp2, textTmp1);
84 
85  textOut=textTmp1[0];
86  return textOut;
87  }
88  else
89  {
90  std::cerr << "diffusionConvolution Smoother: must have tIn < tOut" << std::endl;
91  exit(EXIT_FAILURE);
92  }
93 }
94 
95 
96 }
97 
98 #endif
const T & item(int n) const
Texture< float > AimsMeshLaplacian(const Texture< float > &inittex, const std::map< unsigned, std::set< std::pair< unsigned, float > > > &lapl)
virtual void convert(const INP &in, OUTP &out) const
Texture< T > doSmoothing(const Texture< T > &ima, int maxiter, bool verbose=true)
size_t nItem() const