Engauge Digitizer  2
ColorFilter.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_H
8 #define COLOR_FILTER_H
9 
10 #include "ColorFilterEntry.h"
11 #include "ColorFilterMode.h"
12 #include <QList>
13 #include <QRgb>
14 
15 class QImage;
16 
19 {
20 public:
22  ColorFilter();
23 
25  bool colorCompare (QRgb rgb1,
26  QRgb rgb2) const;
27 
29  void filterImage (const QImage &imageOriginal,
30  QImage &imageFiltered,
31  ColorFilterMode colorFilterMode,
32  double low,
33  double high,
34  QRgb rgbBackground);
35 
39  QRgb marginColor(const QImage *image) const;
40 
42  bool pixelFilteredIsOn (const QImage &image,
43  int x,
44  int y) const;
45 
48  double pixelToZeroToOneOrMinusOne (ColorFilterMode colorFilterMode,
49  const QColor &pixel,
50  QRgb rgbBackground) const;
51 
53  bool pixelUnfilteredIsOn (ColorFilterMode colorFilterMode,
54  const QColor &pixel,
55  QRgb rgbBackground,
56  double low0To1,
57  double high0To1) const;
58 
60  int zeroToOneToValue (ColorFilterMode colorFilterMode,
61  double s) const;
62 
63 private:
64 
65  typedef QList<ColorFilterEntry> ColorList;
66 
67  void mergePixelIntoColorCounts (QRgb pixel,
68  ColorList &colorCounts) const;
69 };
70 
71 #endif // COLOR_FILTER_H
double pixelToZeroToOneOrMinusOne(ColorFilterMode colorFilterMode, const QColor &pixel, QRgb rgbBackground) const
Return pixel converted according to the current filter parameter, normalized to zero to one...
Class for filtering image to remove unimportant information.
Definition: ColorFilter.h:18
int zeroToOneToValue(ColorFilterMode colorFilterMode, double s) const
Inverse of pixelToZeroToOneOrMinusOne.
QRgb marginColor(const QImage *image) const
Identify the margin color of the image, which is defined as the most common color in the four margins...
Definition: ColorFilter.cpp:58
ColorFilter()
Single constructor.
Definition: ColorFilter.cpp:15
bool colorCompare(QRgb rgb1, QRgb rgb2) const
See if the two color values are close enough to be considered to be the same.
Definition: ColorFilter.cpp:19
bool pixelFilteredIsOn(const QImage &image, int x, int y) const
Return true if specified filtered pixel is on.
bool pixelUnfilteredIsOn(ColorFilterMode colorFilterMode, const QColor &pixel, QRgb rgbBackground, double low0To1, double high0To1) const
Return true if specified unfiltered pixel is on.
void filterImage(const QImage &imageOriginal, QImage &imageFiltered, ColorFilterMode colorFilterMode, double low, double high, QRgb rgbBackground)
Filter the original image according to the specified filtering parameters.
Definition: ColorFilter.cpp:26