Engauge Digitizer  2
ColorFilterHistogram.h
1 /******************************************************************************************************
2  * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #ifndef COLOR_FILTER_HISTOGRAM_H
8 #define COLOR_FILTER_HISTOGRAM_H
9 
10 #include <QRgb>
11 
12 class ColorFilter;
13 class QColor;
14 class QImage;
15 
18 {
19 public:
22 
24  int binFromPixel (const ColorFilter &filter,
25  ColorFilterMode colorFilterMode,
26  const QColor &pixel,
27  const QRgb &rgbBackground) const;
28 
32  void generate (const ColorFilter &filter,
33  double histogramBins [],
34  ColorFilterMode colorFilterMode,
35  const QImage &image,
36  int &maxBinCount) const;
37 
39  static int HISTOGRAM_BINS () { return 100; }
40 
42  int valueFromBin (const ColorFilter &filter,
43  ColorFilterMode colorFilterMode,
44  int bin);
45 
46 private:
47 
48  static int FIRST_NON_EMPTY_BIN_AT_START () { return 1; }
49  static int LAST_NON_EMPTY_BIN_AT_END () { return ColorFilterHistogram::HISTOGRAM_BINS () - 2; }
50 };
51 
52 #endif // COLOR_FILTER_HISTOGRAM_H
Class for filtering image to remove unimportant information.
Definition: ColorFilter.h:20
void generate(const ColorFilter &filter, double histogramBins [], ColorFilterMode colorFilterMode, const QImage &image, int &maxBinCount) const
Generate the histogram.
int binFromPixel(const ColorFilter &filter, ColorFilterMode colorFilterMode, const QColor &pixel, const QRgb &rgbBackground) const
Compute histogram bin number from pixel according to filter.
int valueFromBin(const ColorFilter &filter, ColorFilterMode colorFilterMode, int bin)
Inverse of binFromPixel.
ColorFilterHistogram()
Single constructor.
Class that generates a histogram according to the current filter.
static int HISTOGRAM_BINS()
Number of histogram bins.