forked from nmoehrle/mvs-texturing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Histogram.h
41 lines (34 loc) · 1.01 KB
/
Histogram.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once
#include <vector>
#include <string>
#include <fstream>
#include <cstring>
#include <cerrno>
#include <math.h>
#include "util/exception.h"
#include "util/file_system.h"
/**
* Class representing a histogram with a fixed number of bins
* optimized to calculate approximate permilles.
*/
class Histogram {
private:
std::vector<int> bins;
float min;
float max;
int num_values;
public:
/** Constructs a histogram with num_bins bins which clamps values to [_min, _max]. */
Histogram(float _min, float _max, std::size_t num_bins);
/** Adds a value to the histogram. The value is clamped to [min, max]. */
void add_value(float value);
/**
* Saves the histogram to a .csv file.
* @throws util::FileException
*/
void save_to_file(std::string const & filename) const;
/**
* Returns the approximate permille.
*/
float get_approximate_permille(float permille) const;
};