OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
histogram.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 // Copyright (C) 2003-2010 by the IPLT authors
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the Free
9 // Software Foundation; either version 3.0 of the License, or (at your option)
10 // any later version.
11 // This library is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 // details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with this library; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 //------------------------------------------------------------------------------
20 #ifndef OST_IMG_ALG_HISTOGRAM_HH
21 #define OST_IMG_ALG_HISTOGRAM_HH
22 
23 /*
24  Author: Ansgar Philippsen
25 */
26 
27 #include <ost/base.hh>
28 #include <ost/message.hh>
29 
30 #include <ost/img/algorithm.hh>
31 #include <ost/img/image_state.hh>
33 
34 namespace ost { namespace img { namespace alg {
35 
36 class DLLEXPORT HistogramError: public Error {
37 public:
38  virtual ~HistogramError() throw() {} // required for typeinfo visibility
40  Error(String("A histogram error occured: ") + s)
41  {}
42 };
43 
44 
46 {
47 public:
48  typedef std::vector<int> Bins;
49 
50  // default ctor used for explicit instanciation. Don't use!
51  HistogramBase();
53  HistogramBase(int bin_count, Real minimum, Real maximum);
54 
55  // image state algorithm interface
56  template <typename T, class D>
57  void VisitState(const ImageStateImpl<T,D>& isi);
58 
59  void VisitFunction(const Function& f);
60 
61  const Bins& GetBins() const;
62 
63  static String GetAlgorithmName() {return "Histogram";}
64 
65 protected:
66 
67 private:
68  int bin_count_;
69  Real min_,max_,cfac_;
70  Bins bins_;
71 };
72 
73 typedef ImageStateNonModAlgorithm<HistogramBase> Histogram;
74 
75 }
76 
77 OST_IMG_ALG_EXPLICIT_INST_DECL(class,ImageStateNonModAlgorithm<ost::img::alg::HistogramBase>)
78 
79 }} // namespaces
80 
81 #endif