From c8e4271434c7cc4c690d3b6331e25d867f4b8c51 Mon Sep 17 00:00:00 2001 From: Miller Cy Chan Date: Mon, 13 May 2024 11:33:38 +0800 Subject: [PATCH] Add files via upload --- nQuant.Master/GilbertCurve.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nQuant.Master/GilbertCurve.cs b/nQuant.Master/GilbertCurve.cs index d657cc1..829ab78 100644 --- a/nQuant.Master/GilbertCurve.cs +++ b/nQuant.Master/GilbertCurve.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Drawing; -using System.Linq; /* Generalized Hilbert ("gilbert") space-filling curve for rectangular domains of arbitrary (non-power of two) sizes. Copyright (c) 2021 - 2023 Miller Cy Chan @@ -121,7 +120,7 @@ private void DitherPixel(int x, int y) lookup[offset] = ditherable.DitherColorIndex(palette, c2.ToArgb(), bidx) + 1; qPixels[bidx] = lookup[offset] - 1; - if(saliencies != null && CIELABConvertor.Y_Diff(pixel, c2) > palette.Length - margin) { + if(saliencies != null && CIELABConvertor.Y_Diff(pixel, c2) > Math.Max(1, palette.Length - margin)) { var strength = 1 / 3f; c2 = BlueNoise.Diffuse(pixel, palette[qPixels[bidx]], 1 / saliencies[bidx], strength, x, y); qPixels[bidx] = ditherable.DitherColorIndex(palette, c2.ToArgb(), bidx);