Engauge Digitizer
2
Toggle main menu visibility
Loading...
Searching...
No Matches
Color
ColorFilterStrategyForeground.cpp
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
#include "
ColorConstants.h
"
8
#include "
ColorFilterStrategyForeground.h
"
9
#include <QColor>
10
#include <qmath.h>
11
12
ColorFilterStrategyForeground::ColorFilterStrategyForeground
()
13
{
14
}
15
16
ColorFilterStrategyForeground::~ColorFilterStrategyForeground
()
17
{
18
}
19
20
double
ColorFilterStrategyForeground::pixelToZeroToOne
(
const
QColor &pixel,
21
QRgb rgbBackground)
const
22
{
23
double
distance = qSqrt (pow (
double
(pixel.red()) - qRed (rgbBackground), 2) +
24
pow (
double
(pixel.green()) - qGreen (rgbBackground), 2) +
25
pow (
double
(pixel.blue()) - qBlue (rgbBackground), 2));
26
return
distance / qSqrt (255.0 * 255.0 + 255.0 * 255.0 + 255.0 * 255.0);
27
}
28
29
int
ColorFilterStrategyForeground::zeroToOneToValue
(
double
s)
const
30
{
31
return
qFloor (
FOREGROUND_MIN
+ s * (
FOREGROUND_MAX
-
FOREGROUND_MIN
));
32
}
ColorConstants.h
FOREGROUND_MAX
const int FOREGROUND_MAX
Definition
ColorConstants.h:16
FOREGROUND_MIN
const int FOREGROUND_MIN
Definition
ColorConstants.h:15
ColorFilterStrategyForeground.h
ColorFilterStrategyForeground::pixelToZeroToOne
virtual double pixelToZeroToOne(const QColor &pixel, QRgb rgbBackground) const
Return a normalized value of 0 to 1 given input pixel.
Definition
ColorFilterStrategyForeground.cpp:20
ColorFilterStrategyForeground::~ColorFilterStrategyForeground
virtual ~ColorFilterStrategyForeground()
Definition
ColorFilterStrategyForeground.cpp:16
ColorFilterStrategyForeground::zeroToOneToValue
virtual int zeroToOneToValue(double s) const
Return the low value normalized to 0 to 1.
Definition
ColorFilterStrategyForeground.cpp:29
ColorFilterStrategyForeground::ColorFilterStrategyForeground
ColorFilterStrategyForeground()
Single constructor.
Definition
ColorFilterStrategyForeground.cpp:12
Generated on
for Engauge Digitizer by
1.17.0