GteHistogram.h
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #pragma once
9 
10 #include <GTEngineDEF.h>
11 #include <vector>
12 
13 namespace gte
14 {
15 
17 {
18 public:
19  // In the constructor with input 'int const* samples', set noRescaling to
20  // 'true' when you want the sample values mapped directly to the buckets.
21  // Typically, you know that the sample values are in the set of numbers
22  // {0,1,...,numBuckets-1}, but in the event of out-of-range values, the
23  // histogram stores a count for those numbers smaller than 0 and those
24  // numbers larger or equal to numBuckets.
25  Histogram(int numBuckets, int numSamples, int const* samples, bool noRescaling);
26  Histogram(int numBuckets, int numSamples, float const* samples);
27  Histogram(int numBuckets, int numSamples, double const* samples);
28 
29  // Construction where you plan on updating the histogram incrementally.
30  // The incremental update is implemented only for integer samples and
31  // no rescaling.
32  Histogram(int numBuckets);
33 
34  // This function is called when you have used the Histogram(int)
35  // constructor. No bounds checking is used; you must ensure that the
36  // input value is in {0,...,numBuckets-1}.
37  inline void Insert(int value);
38 
39  // This function is called when you have used the Histogram(int)
40  // constructor. Bounds checking is used.
41  void InsertCheck(int value);
42 
43  // Member access.
44  inline std::vector<int> const& GetBuckets() const;
45  inline int GetExcessLess() const;
46  inline int GetExcessGreater() const;
47 
48  // In the following, define cdf(V) = sum_{i=0}^{V} bucket[i], where
49  // 0 <= V < B and B is the number of buckets. Define N = cdf(B-1),
50  // which must be the number of pixels in the image.
51 
52  // Get the lower tail of the histogram. The returned index L has the
53  // properties: cdf(L-1)/N < tailAmount and cdf(L)/N >= tailAmount.
54  int GetLowerTail(double tailAmount);
55 
56  // Get the upper tail of the histogram. The returned index U has the
57  // properties: cdf(U)/N >= 1-tailAmount and cdf(U+1) < 1-tailAmount.
58  int GetUpperTail(double tailAmount);
59 
60  // Get the lower and upper tails of the histogram. The returned indices
61  // are L and U and have the properties:
62  // cdf(L-1)/N < tailAmount/2, cdf(L)/N >= tailAmount/2,
63  // cdf(U)/N >= 1-tailAmount/2, and cdf(U+1) < 1-tailAmount/2.
64  void GetTails(double tailAmount, int& lower, int& upper);
65 
66 private:
67  std::vector<int> mBuckets;
68  int mExcessLess, mExcessGreater;
69 };
70 
71 
72 inline void Histogram::Insert(int value)
73 {
74  ++mBuckets[value];
75 }
76 
77 inline std::vector<int> const& Histogram::GetBuckets() const
78 {
79  return mBuckets;
80 }
81 
82 inline int Histogram::GetExcessLess() const
83 {
84  return mExcessLess;
85 }
86 
87 inline int Histogram::GetExcessGreater() const
88 {
89  return mExcessGreater;
90 }
91 
92 }
void Insert(int value)
Definition: GteHistogram.h:72
GLsizei const GLfloat * value
Definition: glcorearb.h:819
GLsizei samples
Definition: glcorearb.h:1293
int GetExcessLess() const
Definition: GteHistogram.h:82
std::vector< int > const & GetBuckets() const
Definition: GteHistogram.h:77
int GetExcessGreater() const
Definition: GteHistogram.h:87
std::vector< int > mBuckets
Definition: GteHistogram.h:67
#define GTE_IMPEXP
Definition: GTEngineDEF.h:63


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:00