Skip to content

Commit 9b7ecba

Browse files
authored
Add files via upload
1 parent 3983744 commit 9b7ecba

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

nQuantGpp/GilbertCurve.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ namespace Peano
4949
list<ErrorBox> errorq;
5050
vector<float> m_weights;
5151
static uchar DITHER_MAX = 9, ditherMax;
52-
static int margin, nMaxColors, thresold;
52+
static int margin, nMaxColors;
5353
static const float BLOCK_SIZE = 343.0f;
5454

5555
template <typename T> int sign(T val) {
@@ -238,32 +238,25 @@ namespace Peano
238238
error[3] = a_pix - c2[3];
239239

240240
auto denoise = nMaxColors > 2;
241-
auto diffuse = BlueNoise::TELL_BLUE_NOISE[bidx & 4095] > thresold;
242241
error.yDiff = sortedByYDiff ? CIELABConvertor::Y_Diff(pixel, c2) : 1;
243-
auto illusion = !diffuse && BlueNoise::TELL_BLUE_NOISE[(int)(error.yDiff * 4096) & 4095] > thresold;
244242

245243
auto unaccepted = false;
246244
int errLength = denoise ? error.length() - 1 : 0;
247245
for (int j = 0; j < errLength; ++j) {
248-
if (abs(error.p[j]) >= ditherMax) {
246+
if (abs(error[j]) >= ditherMax) {
249247
if (sortedByYDiff && !m_saliencies)
250248
unaccepted = true;
251249

252250
if (m_hasAlpha && m_saliencies == nullptr) {
253-
if (abs(error.p[j]) >= (ditherMax * 2))
254-
error.p[j] = (float)tanh(error.p[j] / maxErr * 20) * (ditherMax - 1);
251+
if (abs(error[j]) >= (ditherMax * M_PI) || error[3] < 1)
252+
error[j] = (float)tanh(error[j] / maxErr * 20) * (ditherMax - 1);
255253
continue;
256254
}
257255

258-
if (diffuse)
259-
error[j] = (float)tanh(error.p[j] / maxErr * 20) * (ditherMax - 1);
260-
else if (illusion)
261-
error[j] = (float)(error.p[j] / maxErr * error.yDiff) * (ditherMax - 1);
262-
else
263-
error[j] /= (float)(1 + sqrt(ditherMax));
256+
error[j] = (float)tanh(error[j] / maxErr * 20) * (ditherMax - 1);
264257
}
265258

266-
if (sortedByYDiff && m_saliencies == nullptr && abs(error.p[j]) >= DITHER_MAX)
259+
if (sortedByYDiff && m_saliencies == nullptr && abs(error[j]) >= DITHER_MAX)
267260
unaccepted = true;
268261
}
269262

@@ -399,7 +392,6 @@ namespace Peano
399392
ditherMax = (uchar)sqr(5 + edge);
400393
else if (weight < .03 && nMaxColors / weight < density && nMaxColors >= 16 && nMaxColors < 256)
401394
ditherMax = (uchar)sqr(5 + edge);
402-
thresold = DITHER_MAX > 9 ? -112 : -64;
403395
m_weights.clear();
404396

405397
if(!sortedByYDiff)

0 commit comments

Comments
 (0)