Skip to content

Commit eaafeab

Browse files
authored
Add files via upload
1 parent 3c9933a commit eaafeab

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

nQuantCpp/GilbertCurve.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ namespace Peano
235235
auto denoise = m_nMaxColor > 2;
236236
auto diffuse = BlueNoise::TELL_BLUE_NOISE[bidx & 4095] > thresold;
237237
error.yDiff = sortedByYDiff ? CIELABConvertor::Y_Diff(pixel, c2) : 1;
238-
auto illusion = !diffuse && BlueNoise::TELL_BLUE_NOISE[(int)(error.yDiff * 4096) & 4095] > thresold;
239238

240239
auto unaccepted = false;
241240
int errLength = denoise ? error.length() - 1 : 0;
@@ -244,12 +243,16 @@ namespace Peano
244243
if (sortedByYDiff && m_saliencies != nullptr)
245244
unaccepted = true;
246245

246+
if (m_hasAlpha && m_saliencies == nullptr) {
247+
if (abs(error.p[j]) >= (ditherMax * 2))
248+
error.p[j] = (float)tanh(error.p[j] / maxErr * 20) * (ditherMax - 1);
249+
continue;
250+
}
251+
247252
if (diffuse)
248253
error[j] = (float)tanh(error.p[j] / maxErr * 20) * (ditherMax - 1);
249-
else if (illusion)
250-
error[j] = (float)(error.p[j] / maxErr * error.yDiff) * (ditherMax - 1);
251254
else
252-
error[j] /= (float)(1 + _sqrt(ditherMax));
255+
unaccepted = true;
253256
}
254257

255258
if (sortedByYDiff && m_saliencies == nullptr && abs(error.p[j]) >= DITHER_MAX)

0 commit comments

Comments
 (0)