seriesstats.hh
Go to the documentation of this file.
/* -*- mia-c++ -*-
*
* This file is part of MIA - a toolbox for medical image analysis
* Copyright (c) Leipzig, Madrid 1999-2017 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
struct SIntensityStats {
double sum;
double sumsq;
double mean;
double variation;
double min;
double max;
size_t n;
};
class EXPORT_CORE FIntensityStatsAccumulator : public TFilter<void>
{
public:
FIntensityStatsAccumulator();
template <typename Container>
void operator () ( const Container& 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
FIntensityStatsAccumulator::FIntensityStatsAccumulator
FIntensityStatsAccumulator()
FIntensityStatsAccumulator::get_result
const SIntensityStats & get_result() const
FIntensityStatsAccumulator::operator()
void operator()(const Container &data)
Definition seriesstats.hh:84
filter.hh
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition defines.hh:33
EXPORT_CORE
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
Definition defines.hh:101
NS_MIA_END
#define NS_MIA_END
conveniance define to end the mia namespace
Definition defines.hh:36
SIntensityStats
data structure to store te results of a statistical analyis of images
Definition seriesstats.hh:33
SIntensityStats::n
size_t n
number of values
Definition seriesstats.hh:47
SIntensityStats::sum
double sum
Sum of all values.
Definition seriesstats.hh:35
SIntensityStats::min
double min
minimum value
Definition seriesstats.hh:43
SIntensityStats::variation
double variation
variation of the values
Definition seriesstats.hh:41
SIntensityStats::mean
double mean
mean of all values
Definition seriesstats.hh:39
SIntensityStats::max
double max
masimum values
Definition seriesstats.hh:45
SIntensityStats::sumsq
double sumsq
Sum of the squares of all values.
Definition seriesstats.hh:37
TFilter
base class for all filer type functors.
Definition core/filter.hh:70