Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mcychan authored Feb 3, 2025
1 parent 85c0bc0 commit ed59fed
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions nQuantCpp/GilbertCurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ namespace Peano

Color c2 = Color::MakeARGB(a_pix, r_pix, g_pix, b_pix);
unsigned short qPixelIndex = 0;
if (m_saliencies != nullptr && (m_nMaxColor < 3 || margin > 6))
if (m_saliencies != nullptr)
{
auto strength = 1 / 3.0f;
auto beta = m_nMaxColor > 8 ? .7f : 1;
Expand All @@ -128,11 +128,15 @@ namespace Peano
else if (m_nMaxColor <= 8 || CIELABConvertor::Y_Diff(pixel, c2) < (2 * acceptedDiff))
c2 = BlueNoise::diffuse(pixel, m_pPalette[qPixelIndex], beta * .5f / m_saliencies[bidx], strength, x, y);

if (m_nMaxColor > 8 && (CIELABConvertor::Y_Diff(pixel, c2) > (beta * acceptedDiff) || CIELABConvertor::U_Diff(pixel, c2) > (2 * acceptedDiff))) {
auto kappa = m_saliencies[bidx] < .25f ? beta * .4f * m_saliencies[bidx] : beta * .4f / m_saliencies[bidx];
Color c1 = Color::MakeARGB(a_pix, r_pix, g_pix, b_pix);
c2 = BlueNoise::diffuse(c1, m_pPalette[qPixelIndex], kappa, strength, x, y);
if (m_nMaxColor < 3 || margin > 6) {
if (m_nMaxColor > 8 && (CIELABConvertor::Y_Diff(pixel, c2) > (beta * acceptedDiff) || CIELABConvertor::U_Diff(pixel, c2) > (2 * acceptedDiff))) {
auto kappa = m_saliencies[bidx] < .25f ? beta * .4f * m_saliencies[bidx] : beta * .4f / m_saliencies[bidx];
Color c1 = Color::MakeARGB(a_pix, r_pix, g_pix, b_pix);
c2 = BlueNoise::diffuse(c1, m_pPalette[qPixelIndex], kappa, strength, x, y);
}
}
else if (m_nMaxColor > 8 && (CIELABConvertor::Y_Diff(pixel, c2) > (beta * acceptedDiff) || CIELABConvertor::U_Diff(pixel, c2) > acceptedDiff))
c2 = Color::MakeARGB(a_pix, r_pix, g_pix, b_pix);

int offset = m_getColorIndexFn(c2);
if (!m_lookup[offset])
Expand Down

0 comments on commit ed59fed

Please sign in to comment.