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 Apr 16, 2024
1 parent d4295b5 commit e45dba4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion nQuantCpp/SpatialQuantizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,16 @@ namespace SpatialQuant
}

if (!dither && nMaxColors > 2) {
Peano::GilbertCurve::dither(bitmapWidth, bitmapHeight, pixels.data(), pPalette->Entries, nMaxColors, nearestColorIndex, GetColorIndex, qPixels.get(), nullptr);
vector<float> saliencies(pixels.size());
const auto saliencyBase = .1f;

for (int i = 0; i < pixels.size(); ++i) {
CIELABConvertor::Lab lab1;
getLab(pixels[i], lab1);
if (lab1.alpha > alphaThreshold)
saliencies[i] = saliencyBase + (1 - saliencyBase) * lab1.L / 100.0f;
}
Peano::GilbertCurve::dither(bitmapWidth, bitmapHeight, pixels.data(), pPalette->Entries, nMaxColors, nearestColorIndex, GetColorIndex, qPixels.get(), saliencies.data());
nearestMap.clear();
}
pixelMap.clear();
Expand Down

0 comments on commit e45dba4

Please sign in to comment.