Skip to content

Commit

Permalink
Update GilbertCurve.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
mcychan authored Nov 3, 2023
1 parent ca1bd6d commit 24afcca
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions nQuantCpp/GilbertCurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace Peano
vector<float> m_weights;
short* m_lookup;
static BYTE DITHER_MAX = 9, ditherMax;
static int margin, thresold;
static int thresold;
static const float BLOCK_SIZE = 343.0f;

template <typename T> int sign(T val) {
Expand Down Expand Up @@ -125,7 +125,7 @@ namespace Peano
m_lookup[offset] = m_ditherFn(m_pPalette, c2.GetValue(), bidx) + 1;
m_qPixels[bidx] = m_lookup[offset] - 1;

if (m_saliencies != nullptr && CIELABConvertor::Y_Diff(pixel, c2) > margin) {
if (m_saliencies != nullptr && CIELABConvertor::Y_Diff(pixel, c2) > m_pPalette->Count - 7) {
auto strength = 1 / 3.0f;
c2 = BlueNoise::diffuse(pixel, m_pPalette->Entries[m_qPixels[bidx]], 1.0f / m_saliencies[bidx], strength, x, y);
m_qPixels[bidx] = m_ditherFn(m_pPalette, c2.GetValue(), bidx);
Expand Down Expand Up @@ -244,7 +244,6 @@ namespace Peano
ditherMax = (BYTE)sqr(5 + edge);
else if (pPalette->Count / weight < 3200 && pPalette->Count > 16 && pPalette->Count < 256)
ditherMax = (BYTE)sqr(5 + edge);
margin = (int) sqr(log2(pPalette->Count) - 1);
thresold = DITHER_MAX > 9 ? -112 : -64;
auto pLookup = make_unique<short[]>(USHRT_MAX + 1);
m_lookup = pLookup.get();
Expand Down

0 comments on commit 24afcca

Please sign in to comment.