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:
39  Error(String("A histogram error occured: ") + s)
40  {}
41 };
42 
43 
45 {
46 public:
47  typedef std::vector<int> Bins;
48 
49  // default ctor used for explicit instanciation. Don't use!
50  HistogramBase();
52  HistogramBase(int bin_count, Real minimum, Real maximum);
53 
54  // image state algorithm interface
55  template <typename T, class D>
56  void VisitState(const ImageStateImpl<T,D>& isi);
57 
58  void VisitFunction(const Function& f);
59 
60  const Bins& GetBins() const;
61 
62  static String GetAlgorithmName() {return "Histogram";}
63 
64 protected:
65 
66 private:
67  int bin_count_;
68  Real min_,max_,cfac_;
69  Bins bins_;
70 };
71 
72 typedef ImageStateNonModAlgorithm<HistogramBase> Histogram;
73 
74 }
75 
76 OST_IMG_ALG_EXPLICIT_INST_DECL(class,ImageStateNonModAlgorithm<ost::img::alg::HistogramBase>)
77 
78 }} // namespaces
79 
80 #endif