aimsalgo 6.0.0
Neuroimaging image processing
histogram.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_HISTOGRAM_H
36#define AIMS_HISTOGRAM_HISTOGRAM_H
37
38#include <cartodata/volume/volume.h>
39#include <fstream>
40
41
42template < class T > class Histogram;
43
44template < class T >
45std::ostream& operator << ( std::ostream& os, const Histogram<T>& thing );
46
48template < class T>
50{
51 public:
52
55
56 Histogram();
58 Histogram( const Histogram<T>& other );
60 virtual ~Histogram() { }
62
65
68 const carto::VolumeRef<int32_t>& data() const { return _data; }
70
73
74 int32_t * beginValid()
75 { return &*_data.begin(); }
76
77 int32_t * endValid()
78 { return &_data.at( _maxValid - _minValid + 1 ); }
79
81 const int32_t * beginValid() const
82 { return &*_data.begin(); }
83
84 const int32_t * endValid() const
85 { return &_data.at( _maxValid - _minValid + 1 ); }
86
87
89 int minValid() const { return _minValid; }
91 int maxValid() const { return _maxValid; }
92
94 int totalPoints() const { return _nPoints; }
95
98 virtual void doit( const carto::rc_ptr<carto::Volume<T> > & ) { }
99
102
103 friend std::ostream& operator << <> ( std::ostream& os,
104 const Histogram<T>& thing );
106
107 protected:
108
115
118};
119
120
121template< class T > inline
123 : _nPoints( 0 ), _minValid( 0 ), _maxValid( 0 )
124{
125}
126
127
128template< class T > inline
130 : _nPoints( other._nPoints ), _minValid( other._minValid ),
131 _maxValid( other._maxValid )
132{
133 _data = other.data().deepcopy();
134}
135
136
137template < class T > inline
138std::ostream& operator << ( std::ostream& os, const Histogram<T>& thing )
139{
140 os << "{nPoints=" << thing._nPoints << ",";
141 os << "minValid=" << thing._minValid << ",";
142 os << "maxValid=" << thing._maxValid << ",";
143 os << "data=" << thing._data << "}";
144
145 return os;
146}
147
148#endif
Base class of histogram container class.
Definition histogram.h:50
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
const carto::VolumeRef< int32_t > & data() const
return a constant reference to the data field of the histogram class.
Definition histogram.h:68
int32_t * endValid()
return the iterator to the last valid value of the histogram
Definition histogram.h:77
virtual ~Histogram()
destructor.
Definition histogram.h:60
Histogram()
constructor.
Definition histogram.h:122
int _nPoints
total number of points
Definition histogram.h:110
int32_t * beginValid()
return the iterator to the first valid value of the histogram
Definition histogram.h:74
int _maxValid
maximum used value
Definition histogram.h:114
virtual void doit(const carto::rc_ptr< carto::Volume< T > > &)
the histogram computation function.
Definition histogram.h:98
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
const int32_t * beginValid() const
return the constant iterator to the first valid value of the histogram
Definition histogram.h:81
const int32_t * endValid() const
return the constant iterator to the last valid value of the histogram
Definition histogram.h:84
std::ostream & operator<<(std::ostream &os, const Histogram< T > &thing)
Definition histogram.h:138
Volume< T > deepcopy(const Volume< T > &src, const std::vector< int > &size=std::vector< int >())