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