approxgm.hh
Go to the documentation of this file.
1 /* -*- mia-c++ -*-
2  *
3  * This file is part of MIA - a toolbox for medical image analysis
4  * Copyright (c) Leipzig, Madrid 1999-2016 Gert Wollny
5  *
6  * MIA is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with MIA; if not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 #ifndef mia_core_approxgm_hh
23 #define mia_core_approxgm_hh
24 
25 #include <mia/core/minimizer.hh>
26 
27 #include <vector>
28 #include <ostream>
29 
31 
33 public:
35  Result(const std::vector<double>& centers);
36  Result(const std::vector<double>& centers,
37  const std::vector<double>& weights,
38  double sigma);
39 
40  Result(const CDoubleVector& x);
41 
42  Result(const Result& orig) = default;
43  Result& operator = (const Result& orig) = default;
44 
45  float value(unsigned x) const;
46 
47  void print(std::ostream& os) const;
48 
49  std::vector<double> m_centers;
50  std::vector<double> m_alpha;
51  double m_sigma;
52  };
53 
54  CApproximateGausianMixture(double epsilon, unsigned max_iter);
56 
57 
58  Result run(const std::vector<float>& data, const std::vector<double>& init_centers) const;
59 
60  template <typename InIterator>
61  Result run(InIterator begin, InIterator end, const std::vector<double>& init_centers) const;
62 
63 private:
64  struct CApproximateGausianMixtureImpl *impl;
65 };
66 
67 std::ostream& operator << (std::ostream& os, const CApproximateGausianMixture::Result& r)
68 {
69  r.print(os);
70  return os;
71 }
72 
73 template <typename InIterator>
75 CApproximateGausianMixture::run(InIterator begin, InIterator end,
76  const std::vector<double>& init_centers) const
77 {
78  std::vector<float> data(begin, end);
79  return run(data, init_centers);
80 }
81 
83 #endif
A wrapper around the c-array to provide an STL like interface for iterators.
Definition: core/vector.hh:75
std::vector< double > m_centers
Definition: approxgm.hh:49
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
std::ostream & operator<<(std::ostream &os, const CApproximateGausianMixture::Result &r)
Definition: approxgm.hh:67
Result run(const std::vector< float > &data, const std::vector< double > &init_centers) const
void print(std::ostream &os) const
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
Definition: defines.hh:101
std::vector< double > m_alpha
Definition: approxgm.hh:50
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36