A.I.M.S algorithms


cumulated.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_HISTOGRAM_CUMULATED_H
36 #define AIMS_HISTOGRAM_CUMULATED_H
37 
39 
41 template< class T >
42 class CumulatedHistogram : public Histogram<T>
43 {
44  public:
45 
52  : Histogram< T >( other ) { }
54  virtual ~CumulatedHistogram() { }
56 
59  void doit( const AimsData<T>& thing );
62  void doit( const SimpleHistogram<T>& thing );
64 
66  int valueForPercentage( float );
67 };
68 
69 
70 
71 template< class T > inline
73 {
74  SimpleHistogram<T> histo;
75 
76  histo.doit( thing );
77  doit( histo );
78 }
79 
80 
81 template< class T > inline
83 {
84  AimsData<int32_t> res( thing.data().dimX() );
85 
86  this->_nPoints = thing.totalPoints();
87  this->_minValid = thing.minValid();
88  this->_maxValid = thing.maxValid();
89 
90  res( 0 ) = thing.data()( 0 );
91 
93  AimsData<int32_t>::iterator out = res.begin() + 1;
94  for ( in = thing.data().begin() + 1; in != thing.data().end(); ++in, ++out )
95  *out = *in + *( out - 1 );
96 
97  this->_data = res;
98 }
99 
100 
101 template< class T > inline
103 {
104  int index = 0;
105  int realValue = (int) ( this->_nPoints * percent / 100. );
106 
107  AimsData<int32_t>::iterator it = this->_data.begin();
108  while ( *it < realValue && it != this->_data.end() )
109  {
110  index++;
111  it++;
112  }
113 
114  return index + this->_minValid;
115 }
116 
117 #endif
virtual ~CumulatedHistogram()
destructor
Definition: cumulated.h:54
int dimX() const
iterator begin()
AimsData< int32_t > & data()
return a reference to the data field of the histogram class.
Definition: histogram.h:66
Classical histogram container class.
Definition: simpleHisto.h:43
int minValid() const
return the minimum valid (used) value of the histogram
Definition: histogram.h:89
CumulatedHistogram()
Constructors and destructor.
Definition: cumulated.h:49
CumulatedHistogram(const CumulatedHistogram< T > &other)
copy constructor
Definition: cumulated.h:51
Base class of histogram container class.
Definition: histogram.h:42
void doit(const AimsData< T > &thing)
classical histogram computation function.
Definition: simpleHisto.h:82
int maxValid() const
returnn the maximum valid (used) value of the histogram
Definition: histogram.h:91
void doit(const AimsData< T > &thing)
computation from an AimsData
Definition: cumulated.h:72
iterator end()
int totalPoints() const
return the total number of points in the histogram
Definition: histogram.h:94
int valueForPercentage(float)
return the bin value for a given percentage
Definition: cumulated.h:102