Skip to content

Commit 73f4ae5

Browse files
authored
Add files via upload
1 parent cb4d6e6 commit 73f4ae5

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

nQuantCpp/GilbertCurve.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,12 @@ namespace Peano
118118
c2 = BlueNoise::diffuse(pixel, m_pPalette[qPixelIndex], beta * 2 / m_saliencies[bidx], strength, x, y);
119119
else if (m_nMaxColor <= 4 || CIELABConvertor::Y_Diff(pixel, c2) < (2 * acceptedDiff)) {
120120
if (m_nMaxColor <= 128 || BlueNoise::TELL_BLUE_NOISE[bidx & 4095] > 0) {
121-
auto kappa = m_saliencies[bidx] < .6f ? beta * .15f / m_saliencies[bidx] : beta * .4f / m_saliencies[bidx];
122-
c2 = BlueNoise::diffuse(pixel, m_pPalette[qPixelIndex], kappa, strength, x, y);
121+
if (m_nMaxColor > 32) {
122+
auto kappa = m_saliencies[bidx] < .6f ? beta * .15f / m_saliencies[bidx] : beta * .4f / m_saliencies[bidx];
123+
c2 = BlueNoise::diffuse(pixel, m_pPalette[qPixelIndex], kappa, strength, x, y);
124+
}
125+
else if(m_saliencies[bidx] < .9)
126+
c2 = BlueNoise::diffuse(pixel, m_pPalette[qPixelIndex], beta * .5f / m_saliencies[bidx], strength, x, y);
123127
}
124128
if (CIELABConvertor::U_Diff(pixel, c2) > (margin * acceptedDiff))
125129
c2 = BlueNoise::diffuse(pixel, m_pPalette[qPixelIndex], beta / m_saliencies[bidx], strength, x, y);
@@ -154,8 +158,8 @@ namespace Peano
154158
c2 = Color::MakeARGB(a_pix, r_pix, g_pix, b_pix);
155159
}
156160

157-
if (DITHER_MAX < 16 && m_nMaxColor > 4 && m_saliencies[bidx] < .6f && CIELABConvertor::Y_Diff(pixel, c2) > margin - 1)
158-
c2 = Color::MakeARGB(a_pix, r_pix, g_pix, b_pix);
161+
if (!sortedByYDiff && m_nMaxColor > 32 && (m_nMaxColor <= 64 || m_weight >= .02) && CIELABConvertor::Y_Diff(pixel, c2) > margin - 1)
162+
c2 = BlueNoise::diffuse(pixel, m_pPalette[qPixelIndex], beta * normalDistribution(beta, m_nMaxColor / 128.0f) * m_saliencies[bidx], strength, x, y);
159163
if (beta > 1 && CIELABConvertor::Y_Diff(pixel, c2) > DITHER_MAX)
160164
c2 = Color::MakeARGB(a_pix, r_pix, g_pix, b_pix);
161165

@@ -368,7 +372,7 @@ namespace Peano
368372
if (m_nMaxColor > 64 || (m_nMaxColor > 4 && weight > .02))
369373
beta *= .4f;
370374
if (m_nMaxColor > 64 && weight < .02)
371-
beta = .18f;
375+
beta = .18f;
372376

373377
DITHER_MAX = weight < .015 ? (weight > .0025) ? (BYTE)25 : 16 : 9;
374378
if (weight > .99) {

0 commit comments

Comments
 (0)