00001
00002
00003
00004
00005
00006
00007 #include "ColorConstants.h"
00008 #include "ColorFilterStrategyForeground.h"
00009 #include <QColor>
00010 #include <qmath.h>
00011
00012 ColorFilterStrategyForeground::ColorFilterStrategyForeground ()
00013 {
00014 }
00015
00016 ColorFilterStrategyForeground::~ColorFilterStrategyForeground ()
00017 {
00018 }
00019
00020 double ColorFilterStrategyForeground::pixelToZeroToOne (const QColor &pixel,
00021 QRgb rgbBackground) const
00022 {
00023 double distance = qSqrt (pow ((double) pixel.red() - qRed (rgbBackground), 2) +
00024 pow ((double) pixel.green() - qGreen (rgbBackground), 2) +
00025 pow ((double) pixel.blue() - qBlue (rgbBackground), 2));
00026 return distance / qSqrt (255.0 * 255.0 + 255.0 * 255.0 + 255.0 * 255.0);
00027 }
00028
00029 int ColorFilterStrategyForeground::zeroToOneToValue (double s) const
00030 {
00031 return FOREGROUND_MIN + s * (FOREGROUND_MAX - FOREGROUND_MIN);
00032 }