1 Changes the "Sharpen" effect to Blitz::sharpen() instead of
2 Blitz::gaussianSharpen(), in order to avoid parameters that are currently
3 set in a dangerously adhoc fashion (radius, sigma, repeat).
5 Unfortunately, the results do not look good.
10 Index: imagelib/effects/kpEffectBlurSharpen.cpp
11 ===================================================================
12 --- imagelib/effects/kpEffectBlurSharpen.cpp (revision 699849)
13 +++ imagelib/effects/kpEffectBlurSharpen.cpp (working copy)
18 -#define DEBUG_KP_EFFECT_BLUR_SHARPEN 0
19 +#define DEBUG_KP_EFFECT_BLUR_SHARPEN 1
22 #include <kpEffectBlurSharpen.h>
27 -static QImage BlurQImage (const QImage qimage_, int strength)
28 +static int RadiusForStrength (int strength)
30 - QImage qimage = qimage_;
35 - // The numbers that follow were picked by experimentation to try to get
36 - // an effect linearly proportional to <strength> and at the same time,
39 - // I still have no idea what "radius" means.
40 + // (must be in range and not 0)
41 + Q_ASSERT (strength > 0 && strength <= kpEffectBlurSharpen::MaxStrength);
43 const double RadiusMin = 1;
44 const double RadiusMax = 10;
45 @@ -67,92 +59,36 @@ static QImage BlurQImage (const QImage q
46 (kpEffectBlurSharpen::MaxStrength - 1);
48 #if DEBUG_KP_EFFECT_BLUR_SHARPEN
49 - kDebug () << "kpEffectBlurSharpen.cpp:BlurQImage(strength=" << strength << ")"
50 + kDebug () << "kpEffectBlurSharpen.cpp:RadiusForStrength(strength=" << strength << ")"
51 << " radius=" << radius
56 - qimage = Blitz::blur (qimage, qRound (radius));
60 + return qRound (radius);
63 -static QImage SharpenQImage (const QImage &qimage_, int strength)
65 +static QImage BlurQImage (const QImage qimage_, int strength)
67 QImage qimage = qimage_;
72 - // The numbers that follow were picked by experimentation to try to get
73 - // an effect linearly proportional to <strength> and at the same time,
76 - // I still have no idea what "radius" and "sigma" mean.
78 - const double RadiusMin = .1;
79 - const double RadiusMax = 2.5;
80 - const double radius = RadiusMin +
82 - (RadiusMax - RadiusMin) /
83 - (kpEffectBlurSharpen::MaxStrength - 1);
85 - const double SigmaMin = .5;
86 - const double SigmaMax = 3.0;
87 - const double sigma = SigmaMin +
89 - (SigmaMax - SigmaMin) /
90 - (kpEffectBlurSharpen::MaxStrength - 1);
92 - const double RepeatMin = 1;
93 - const double RepeatMax = 2;
94 - const double repeat = qRound (RepeatMin +
96 - (RepeatMax - RepeatMin) /
97 - (kpEffectBlurSharpen::MaxStrength - 1));
98 + qimage = Blitz::blur (qimage, ::RadiusForStrength (strength));
100 -// I guess these values are more proper as they use an auto-calculated
101 -// radius but they cause sharpen() to be too slow.
103 - const double radius = 0/*auto-calculate*/;
105 - const double SigmaMin = .6;
106 - const double SigmaMax = 1.0;
107 - const double sigma = SigmaMin +
109 - (SigmaMax - SigmaMin) /
110 - (kpEffectBlurSharpen::MaxStrength - 1);
112 - const double RepeatMin = 1;
113 - const double RepeatMax = 3;
114 - const double repeat = qRound (RepeatMin +
116 - (RepeatMax - RepeatMin) /
117 - (kpEffectBlurSharpen::MaxStrength - 1));
122 -#if DEBUG_KP_EFFECT_BLUR_SHARPEN
123 - kDebug () << "kpEffectBlurSharpen.cpp:SharpenQImage(strength=" << strength << ")"
124 - << " radius=" << radius
125 - << " sigma=" << sigma
126 - << " repeat=" << repeat
129 +static QImage SharpenQImage (const QImage &qimage_, int strength)
131 + QImage qimage = qimage_;
136 - for (int i = 0; i < repeat; i++)
138 - #if DEBUG_KP_EFFECT_BLUR_SHARPEN
139 - QTime timer; timer.start ();
141 - qimage = Blitz::gaussianSharpen (qimage, radius, sigma);
142 - #if DEBUG_KP_EFFECT_BLUR_SHARPEN
143 - kDebug () << "\titeration #" + QString::number (i)
144 - << ": " + QString::number (timer.elapsed ()) << "ms" << endl;
147 + qimage = Blitz::sharpen (qimage, ::RadiusForStrength (strength) * 10);