Engauge Digitizer 2
Loading...
Searching...
No Matches
ColorFilter.h
Go to the documentation of this file.
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 <QMap>
14#include <QRgb>
15
17class QImage;
18
21{
22public:
25
28
30 bool colorCompare (QRgb rgb1,
31 QRgb rgb2) const;
32
34 void filterImage (const QImage &imageOriginal,
35 QImage &imageFiltered,
36 ColorFilterMode colorFilterMode,
37 double low,
38 double high,
39 QRgb rgbBackground);
40
44 QRgb marginColor(const QImage *image) const;
45
47 bool pixelFilteredIsOn (const QImage &image,
48 int x,
49 int y) const;
50
53 double pixelToZeroToOneOrMinusOne (ColorFilterMode colorFilterMode,
54 const QColor &pixel,
55 QRgb rgbBackground) const;
56
58 bool pixelUnfilteredIsOn (ColorFilterMode colorFilterMode,
59 const QColor &pixel,
60 QRgb rgbBackground,
61 double low0To1,
62 double high0To1) const;
63
65 int zeroToOneToValue (ColorFilterMode colorFilterMode,
66 double s) const;
67
68private:
69
70 void createStrategies ();
71
72 typedef QList<ColorFilterEntry> ColorList;
73
74 void mergePixelIntoColorCounts (QRgb pixel,
75 ColorList &colorCounts) const;
76
77 // Strategies for mode-specific computations
78 QMap<ColorFilterMode, ColorFilterStrategyAbstractBase*> m_strategies;
79
80};
81
82#endif // COLOR_FILTER_H
ColorFilterMode
Base class for strategy pattern whose subclasses process the different color filter settings modes (o...
Class for filtering image to remove unimportant information.
Definition ColorFilter.h:21
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...
bool pixelFilteredIsOn(const QImage &image, int x, int y) const
Return true if specified filtered 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.
~ColorFilter()
Destructor deallocates memory.
int zeroToOneToValue(ColorFilterMode colorFilterMode, double s) const
Inverse of pixelToZeroToOneOrMinusOne.
bool pixelUnfilteredIsOn(ColorFilterMode colorFilterMode, const QColor &pixel, QRgb rgbBackground, double low0To1, double high0To1) const
Return true if specified unfiltered pixel is on.
double pixelToZeroToOneOrMinusOne(ColorFilterMode colorFilterMode, const QColor &pixel, QRgb rgbBackground) const
Return pixel converted according to the current filter parameter, normalized to zero to one.
ColorFilter()
Single constructor.
bool colorCompare(QRgb rgb1, QRgb rgb2) const
See if the two color values are close enough to be considered to be the same.