/usr/include/mia-2.2/mia/core/seriesstats.hh is in libmia-2.2-dev 2.2.2-1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | /* -*- mia-c++ -*-
*
* This file is part of MIA - a toolbox for medical image analysis
* Copyright (c) Leipzig, Madrid 1999-2014 Gert Wollny
*
* MIA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MIA; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef mia_2d_seriesstats_hh
#define mia_2d_seriesstats_hh
#include <mia/core/filter.hh>
NS_MIA_BEGIN
/**
\ingroup misc
\brief data structure to store te results of a statistical analyis of images
*/
struct SIntensityStats {
/// Sum of all values
double sum;
/// Sum of the squares of all values
double sumsq;
/// mean of all values
double mean;
/// variation of the values
double variation;
/// minimum value
double min;
/// masimum values
double max;
/// number of values
size_t n;
};
/**
\ingroup misc
\brief Functor to accumulate statistics of data.
This functior is used to accumulate the statistics over the data various
containers or images.
*/
class EXPORT_CORE FIntensityStatsAccumulator : public TFilter<void> {
public:
FIntensityStatsAccumulator();
/**
This function gets called for each entity from the input that the statistics is
evaluated for.
\param @data the data container to be processed
*/
template <typename Container>
void operator () ( const Container& data);
/**
Evaluate the statistics and return it
\returns the statistical measures of the accumulated data
*/
const SIntensityStats& get_result() const;
private:
mutable SIntensityStats m_stats;
mutable bool m_stats_valid;
};
template <typename Container>
void FIntensityStatsAccumulator::operator () ( const Container& data)
{
m_stats_valid = false;
m_stats.n += data.size();
for (auto i = data.begin(); i != data.end(); ++i) {
m_stats.sum += *i;
m_stats.sumsq += *i * *i;
if (m_stats.min > *i)
m_stats.min = *i;
if (m_stats.max < *i)
m_stats.max = *i;
}
}
NS_MIA_END
#endif
|