diff --git a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs
index 1136fbc9da..fe422882bc 100644
--- a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs
@@ -60,7 +60,7 @@ public OctreeQuantizer(Configuration configuration, QuantizerOptions options)
public QuantizerOptions Options { get; }
///
- public ReadOnlyMemory Palette
+ public readonly ReadOnlyMemory Palette
{
get
{
@@ -72,16 +72,14 @@ public ReadOnlyMemory Palette
///
public void AddPaletteColors(Buffer2DRegion pixelRegion)
{
- Rectangle bounds = pixelRegion.Rectangle;
- Buffer2D source = pixelRegion.Buffer;
- using (IMemoryOwner buffer = this.Configuration.MemoryAllocator.Allocate(bounds.Width))
+ using (IMemoryOwner buffer = this.Configuration.MemoryAllocator.Allocate(pixelRegion.Width))
{
Span bufferSpan = buffer.GetSpan();
// Loop through each row
- for (int y = bounds.Top; y < bounds.Bottom; y++)
+ for (int y = 0; y < pixelRegion.Height; y++)
{
- Span row = source.DangerousGetRowSpan(y).Slice(bounds.Left, bounds.Width);
+ Span row = pixelRegion.DangerousGetRowSpan(y);
PixelOperations.Instance.ToRgba32(this.Configuration, row, bufferSpan);
for (int x = 0; x < bufferSpan.Length; x++)
diff --git a/src/ImageSharp/Processing/Processors/Quantization/QuantizeProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/QuantizeProcessor{TPixel}.cs
index f8be91bc2b..da2580fedf 100644
--- a/src/ImageSharp/Processing/Processors/Quantization/QuantizeProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Quantization/QuantizeProcessor{TPixel}.cs
@@ -32,7 +32,7 @@ public QuantizeProcessor(Configuration configuration, IQuantizer quantizer, Imag
///
protected override void OnFrameApply(ImageFrame source)
{
- var interest = Rectangle.Intersect(source.Bounds(), this.SourceRectangle);
+ Rectangle interest = Rectangle.Intersect(source.Bounds(), this.SourceRectangle);
Configuration configuration = this.Configuration;
using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration);
@@ -43,14 +43,14 @@ protected override void OnFrameApply(ImageFrame source)
int offsetX = interest.Left;
Buffer2D sourceBuffer = source.PixelBuffer;
- for (int y = interest.Y; y < interest.Height; y++)
+ for (int y = 0; y < quantized.Height; y++)
{
- Span row = sourceBuffer.DangerousGetRowSpan(y);
- ReadOnlySpan quantizedRow = quantized.DangerousGetRowSpan(y - offsetY);
+ ReadOnlySpan quantizedRow = quantized.DangerousGetRowSpan(y);
+ Span row = sourceBuffer.DangerousGetRowSpan(y + offsetY);
- for (int x = interest.Left; x < interest.Right; x++)
+ for (int x = 0; x < quantized.Width; x++)
{
- row[x] = paletteSpan[quantizedRow[x - offsetX]];
+ row[x + offsetX] = paletteSpan[quantizedRow[x]];
}
}
}
diff --git a/src/ImageSharp/Processing/Processors/Quantization/QuantizerUtilities.cs b/src/ImageSharp/Processing/Processors/Quantization/QuantizerUtilities.cs
index 53203f94a0..a7edec662e 100644
--- a/src/ImageSharp/Processing/Processors/Quantization/QuantizerUtilities.cs
+++ b/src/ImageSharp/Processing/Processors/Quantization/QuantizerUtilities.cs
@@ -154,14 +154,14 @@ private static void SecondPass(
int offsetY = bounds.Top;
int offsetX = bounds.Left;
- for (int y = bounds.Y; y < bounds.Height; y++)
+ for (int y = 0; y < destination.Height; y++)
{
- Span sourceRow = sourceBuffer.DangerousGetRowSpan(y);
- Span destinationRow = destination.GetWritablePixelRowSpanUnsafe(y - offsetY);
+ Span sourceRow = sourceBuffer.DangerousGetRowSpan(y + offsetY);
+ Span destinationRow = destination.GetWritablePixelRowSpanUnsafe(y);
- for (int x = bounds.Left; x < bounds.Right; x++)
+ for (int x = 0; x < destination.Width; x++)
{
- destinationRow[x - offsetX] = Unsafe.AsRef(quantizer).GetQuantizedColor(sourceRow[x], out TPixel _);
+ destinationRow[x] = Unsafe.AsRef(quantizer).GetQuantizedColor(sourceRow[x + offsetX], out TPixel _);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs
index 524153804c..f6928c3dd4 100644
--- a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs
@@ -123,10 +123,11 @@ public readonly ReadOnlyMemory Palette
///
public void AddPaletteColors(Buffer2DRegion pixelRegion)
{
- Rectangle bounds = pixelRegion.Rectangle;
- Buffer2D source = pixelRegion.Buffer;
-
- this.Build3DHistogram(source, bounds);
+ // TODO: Something is destroying the existing palette when adding new colors.
+ // When the QuantizingImageEncoder.PixelSamplingStrategy is DefaultPixelSamplingStrategy
+ // this leads to performance issues + the palette is not preserved.
+ // https://github.com/SixLabors/ImageSharp/issues/2498
+ this.Build3DHistogram(pixelRegion);
this.Get3DMoments(this.memoryAllocator);
this.BuildCube();
@@ -360,19 +361,18 @@ private static Moment Top(ref Box cube, int direction, int position, ReadOnlySpa
///
/// Builds a 3-D color histogram of counts, r/g/b, c^2.
///
- /// The source data.
- /// The bounds within the source image to quantize.
- private readonly void Build3DHistogram(Buffer2D source, Rectangle bounds)
+ /// The source pixel data.
+ private readonly void Build3DHistogram(Buffer2DRegion source)
{
Span momentSpan = this.momentsOwner.GetSpan();
// Build up the 3-D color histogram
- using IMemoryOwner buffer = this.memoryAllocator.Allocate(bounds.Width);
+ using IMemoryOwner buffer = this.memoryAllocator.Allocate(source.Width);
Span bufferSpan = buffer.GetSpan();
- for (int y = bounds.Top; y < bounds.Bottom; y++)
+ for (int y = 0; y < source.Height; y++)
{
- Span row = source.DangerousGetRowSpan(y).Slice(bounds.Left, bounds.Width);
+ Span row = source.DangerousGetRowSpan(y);
PixelOperations.Instance.ToRgba32(this.Configuration, row, bufferSpan);
for (int x = 0; x < bufferSpan.Length; x++)
diff --git a/tests/ImageSharp.Tests/Processing/Processors/Quantization/QuantizerTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Quantization/QuantizerTests.cs
index d26032c7ef..b8b4615b94 100644
--- a/tests/ImageSharp.Tests/Processing/Processors/Quantization/QuantizerTests.cs
+++ b/tests/ImageSharp.Tests/Processing/Processors/Quantization/QuantizerTests.cs
@@ -12,74 +12,66 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Quantization;
[Trait("Category", "Processors")]
public class QuantizerTests
{
- ///
- /// Something is causing tests to fail on NETFX in CI.
- /// Could be a JIT error as everything runs well and is identical to .NET Core output.
- /// Not worth investigating for now.
- ///
- ///
- private static readonly bool SkipAllQuantizerTests = TestEnvironment.IsFramework;
-
public static readonly string[] CommonTestImages =
{
TestImages.Png.CalliphoraPartial,
TestImages.Png.Bike
};
- private static readonly QuantizerOptions NoDitherOptions = new QuantizerOptions { Dither = null };
- private static readonly QuantizerOptions DiffuserDitherOptions = new QuantizerOptions { Dither = KnownDitherings.FloydSteinberg };
- private static readonly QuantizerOptions OrderedDitherOptions = new QuantizerOptions { Dither = KnownDitherings.Bayer8x8 };
+ private static readonly QuantizerOptions NoDitherOptions = new() { Dither = null };
+ private static readonly QuantizerOptions DiffuserDitherOptions = new() { Dither = KnownDitherings.FloydSteinberg };
+ private static readonly QuantizerOptions OrderedDitherOptions = new() { Dither = KnownDitherings.Bayer8x8 };
- private static readonly QuantizerOptions Diffuser0_ScaleDitherOptions = new QuantizerOptions
+ private static readonly QuantizerOptions Diffuser0_ScaleDitherOptions = new()
{
Dither = KnownDitherings.FloydSteinberg,
DitherScale = 0F
};
- private static readonly QuantizerOptions Diffuser0_25_ScaleDitherOptions = new QuantizerOptions
+ private static readonly QuantizerOptions Diffuser0_25_ScaleDitherOptions = new()
{
Dither = KnownDitherings.FloydSteinberg,
DitherScale = .25F
};
- private static readonly QuantizerOptions Diffuser0_5_ScaleDitherOptions = new QuantizerOptions
+ private static readonly QuantizerOptions Diffuser0_5_ScaleDitherOptions = new()
{
Dither = KnownDitherings.FloydSteinberg,
DitherScale = .5F
};
- private static readonly QuantizerOptions Diffuser0_75_ScaleDitherOptions = new QuantizerOptions
+ private static readonly QuantizerOptions Diffuser0_75_ScaleDitherOptions = new()
{
Dither = KnownDitherings.FloydSteinberg,
DitherScale = .75F
};
- private static readonly QuantizerOptions Ordered0_ScaleDitherOptions = new QuantizerOptions
+ private static readonly QuantizerOptions Ordered0_ScaleDitherOptions = new()
{
Dither = KnownDitherings.Bayer8x8,
DitherScale = 0F
};
- private static readonly QuantizerOptions Ordered0_25_ScaleDitherOptions = new QuantizerOptions
+ private static readonly QuantizerOptions Ordered0_25_ScaleDitherOptions = new()
{
Dither = KnownDitherings.Bayer8x8,
DitherScale = .25F
};
- private static readonly QuantizerOptions Ordered0_5_ScaleDitherOptions = new QuantizerOptions
+ private static readonly QuantizerOptions Ordered0_5_ScaleDitherOptions = new()
{
Dither = KnownDitherings.Bayer8x8,
DitherScale = .5F
};
- private static readonly QuantizerOptions Ordered0_75_ScaleDitherOptions = new QuantizerOptions
+ private static readonly QuantizerOptions Ordered0_75_ScaleDitherOptions = new()
{
Dither = KnownDitherings.Bayer8x8,
DitherScale = .75F
};
public static readonly TheoryData Quantizers
- = new TheoryData
+ = new()
{
// Known uses error diffusion by default.
KnownQuantizers.Octree,
@@ -97,7 +89,7 @@ public static readonly TheoryData Quantizers
};
public static readonly TheoryData DitherScaleQuantizers
- = new TheoryData
+ = new()
{
new OctreeQuantizer(Diffuser0_ScaleDitherOptions),
new WebSafePaletteQuantizer(Diffuser0_ScaleDitherOptions),
@@ -151,7 +143,7 @@ public static readonly TheoryData DitherScaleQuantizers
};
public static readonly TheoryData DefaultInstanceDitherers
- = new TheoryData
+ = new()
{
default(ErrorDither),
default(OrderedDither)
@@ -164,11 +156,6 @@ public static readonly TheoryData DefaultInstanceDitherers
public void ApplyQuantizationInBox(TestImageProvider provider, IQuantizer quantizer)
where TPixel : unmanaged, IPixel
{
- if (SkipAllQuantizerTests)
- {
- return;
- }
-
string quantizerName = quantizer.GetType().Name;
string ditherName = quantizer.Options.Dither?.GetType()?.Name ?? "NoDither";
string testOutputDetails = $"{quantizerName}_{ditherName}";
@@ -185,11 +172,6 @@ public void ApplyQuantizationInBox(TestImageProvider provider, I
public void ApplyQuantization(TestImageProvider provider, IQuantizer quantizer)
where TPixel : unmanaged, IPixel
{
- if (SkipAllQuantizerTests)
- {
- return;
- }
-
string quantizerName = quantizer.GetType().Name;
string ditherName = quantizer.Options.Dither?.GetType()?.Name ?? "NoDither";
string testOutputDetails = $"{quantizerName}_{ditherName}";
@@ -206,11 +188,6 @@ public void ApplyQuantization(TestImageProvider provider, IQuant
public void ApplyQuantizationWithDitheringScale(TestImageProvider provider, IQuantizer quantizer)
where TPixel : unmanaged, IPixel
{
- if (SkipAllQuantizerTests)
- {
- return;
- }
-
string quantizerName = quantizer.GetType().Name;
string ditherName = quantizer.Options.Dither.GetType().Name;
float ditherScale = quantizer.Options.DitherScale;
@@ -229,8 +206,8 @@ public void ShouldThrowForDefaultDitherInstance(IDither dither)
{
void Command()
{
- using var image = new Image(10, 10);
- var quantizer = new WebSafePaletteQuantizer();
+ using Image image = new(10, 10);
+ WebSafePaletteQuantizer quantizer = new();
quantizer.Options.Dither = dither;
image.Mutate(x => x.Quantize(quantizer));
}
diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_OctreeQuantizer_ErrorDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_OctreeQuantizer_ErrorDither.png
index 4011bbc38e..a7730d4e65 100644
--- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_OctreeQuantizer_ErrorDither.png
+++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_OctreeQuantizer_ErrorDither.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:df15b095693880ec25f4fda378c8404a55064d83a40fc889f4e7ebb251dd88cf
-size 272529
+oid sha256:f4d36c8f7e5d5c0d798af5fb6bfad28ed0d628b880bea81efe0d54ac1fde86b2
+size 265268
diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_OctreeQuantizer_NoDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_OctreeQuantizer_NoDither.png
index 0c53f8d42d..d993923d48 100644
--- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_OctreeQuantizer_NoDither.png
+++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_OctreeQuantizer_NoDither.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:fd18f2ba17869695efda6acf7daa0f4def11a4f5ba6cee95e06cee505f076c77
-size 263994
+oid sha256:9f165908729d723818b6c5843bd75298d987448e2cd4278dfe3f388a62025add
+size 238396
diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_OctreeQuantizer_OrderedDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_OctreeQuantizer_OrderedDither.png
index ff1e888096..223d3bc012 100644
--- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_OctreeQuantizer_OrderedDither.png
+++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_OctreeQuantizer_OrderedDither.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:7bcd315c4f140b55b294216de83f7835dcdf027acbd9cdb5e8bcbd89360c4781
-size 272971
+oid sha256:34eaa0696da00838e591b2c48e7797641521f7f3feb01abbd774591c4dd6f200
+size 265546
diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WebSafePaletteQuantizer_ErrorDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WebSafePaletteQuantizer_ErrorDither.png
index 081e6dbdfe..367db5ea10 100644
--- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WebSafePaletteQuantizer_ErrorDither.png
+++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WebSafePaletteQuantizer_ErrorDither.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:fb9b649fd0b217ce548d46b0e7958f5ab74b5862678d34839d7b7ab29e3722ee
-size 255871
+oid sha256:531594a2e47710545d96d0fd9a8cc86983233420172e0ced28df050df1a5e039
+size 239844
diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WebSafePaletteQuantizer_NoDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WebSafePaletteQuantizer_NoDither.png
index c0186e4272..922c2bf9b2 100644
--- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WebSafePaletteQuantizer_NoDither.png
+++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WebSafePaletteQuantizer_NoDither.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:c0374d786d726692e83022a5d8642807ad24f9d484393d564a4cc73a3f8971f8
-size 250230
+oid sha256:4f1462733e02d499b0d8c61ab835a27c7fee560fdc7fc521d20ec09bb4ccc80f
+size 216030
diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WebSafePaletteQuantizer_OrderedDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WebSafePaletteQuantizer_OrderedDither.png
index 05f9404ed1..29c93d14e2 100644
--- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WebSafePaletteQuantizer_OrderedDither.png
+++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WebSafePaletteQuantizer_OrderedDither.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:a8a9f1fab68b71ae87b7f8f8fa61cd73c6e868359bff60e91c1246eb04c92740
-size 252981
+oid sha256:7e6d91a3ec4f974af675dc360fd5fd623ec8773cdbc88c0a3a6506880838718a
+size 226727
diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WernerPaletteQuantizer_ErrorDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WernerPaletteQuantizer_ErrorDither.png
index 1eeabc6664..f8b5e61332 100644
--- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WernerPaletteQuantizer_ErrorDither.png
+++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WernerPaletteQuantizer_ErrorDither.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:216d096da3a1e5df9cffa1dddc2c136c4ad0db1ca3ff930a46193352680e91d6
-size 257442
+oid sha256:620463c14de12abb4f2cab3ee6259ad8cbb24c688212729535f41ebf492a8836
+size 224490
diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WernerPaletteQuantizer_NoDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WernerPaletteQuantizer_NoDither.png
index afa308a920..dbfab2b508 100644
--- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WernerPaletteQuantizer_NoDither.png
+++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WernerPaletteQuantizer_NoDither.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:8c15a5b6114825ff1f118209831a89d8619ea2c956ad52f9564dfc41be94c6cb
-size 255797
+oid sha256:c68eba122814b5470e5f2e03e34190ff79e84e4b431ad8227355ce7ffcd4a6a7
+size 220192
diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WernerPaletteQuantizer_OrderedDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WernerPaletteQuantizer_OrderedDither.png
index 2d61083331..86655af42b 100644
--- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WernerPaletteQuantizer_OrderedDither.png
+++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WernerPaletteQuantizer_OrderedDither.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:9694b6b29e33c5b0b5a8f662246f5ad0af03b900d52615fa61cad6d16cebb31c
-size 259740
+oid sha256:6dbd3189b559941f91dd6e0aa15b34a3e5081477400678c2396c6a66d398876f
+size 230883
diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WuQuantizer_ErrorDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WuQuantizer_ErrorDither.png
index 82c6b3ed58..a9e5e18dfa 100644
--- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WuQuantizer_ErrorDither.png
+++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WuQuantizer_ErrorDither.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:cc776a1039f25212cbe983ae41de4bc3d8e53dd3f692c327da42d91fe983fe5d
-size 275846
+oid sha256:274c3e57f186c47bb070dfd2a79b8353032f9d91d03a3ab9ecb3aec13fdd9855
+size 273333
diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WuQuantizer_NoDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WuQuantizer_NoDither.png
index 5ea0460c1c..d8a1178adc 100644
--- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WuQuantizer_NoDither.png
+++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WuQuantizer_NoDither.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:8aced00a35f19ccb7011cc7ef04bcbe79b064078a5b7b1649ecab789da13160e
-size 273774
+oid sha256:df63a3d12e2998d5242b64169ac86e3df7ab4be585a80daddc3e3888dfcb7095
+size 262298
diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WuQuantizer_OrderedDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WuQuantizer_OrderedDither.png
index d96ad1e233..76946ee06f 100644
--- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WuQuantizer_OrderedDither.png
+++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_Bike_WuQuantizer_OrderedDither.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:f4fe9d03e33808cf97e6ee3a4a877160b04746e46a3e3c56c0cdf7ab617e90d9
-size 276397
+oid sha256:457a0b4e27a09440ff4e13792b68fb5a9da82b7ce6129ea15a5ea8dcd99bd522
+size 274300
diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_OctreeQuantizer_ErrorDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_OctreeQuantizer_ErrorDither.png
index 0e1781b119..b5cb6c0fa8 100644
--- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_OctreeQuantizer_ErrorDither.png
+++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_OctreeQuantizer_ErrorDither.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:2358c7b0c3de1f13d9d7840108ffd1b65751946ba28a697d6ae48b7445541807
-size 308226
+oid sha256:fd007786164af8f410bd9738c0a072fc75d1f9b50145e5c191c9e3df345341a5
+size 318778
diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_OctreeQuantizer_NoDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_OctreeQuantizer_NoDither.png
index 5c58149639..7e3080562c 100644
--- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_OctreeQuantizer_NoDither.png
+++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_OctreeQuantizer_NoDither.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:38c112f9edef86df31b8ccec63bffdd3d4426eb5fd44b774bef4166c70f31a90
-size 303086
+oid sha256:0203ecb9e4665e7c3992b7da4777c6d35b539790506fc9ca2acbcbc2bdb5db18
+size 303979
diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_OctreeQuantizer_OrderedDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_OctreeQuantizer_OrderedDither.png
index 1b7ed02df8..5626fa1b83 100644
--- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_OctreeQuantizer_OrderedDither.png
+++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_OctreeQuantizer_OrderedDither.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:93fd2a28153ec292c0d6b2651830566fa3ee0cdcad7f6978ff8b49cd7fb2ac27
-size 308104
+oid sha256:62cdce27fc46a38a16995df8ed1501f65091d69315288479b1d613b1d87c8239
+size 321123
diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WebSafePaletteQuantizer_ErrorDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WebSafePaletteQuantizer_ErrorDither.png
index a4d2d92a53..3ae9d369d6 100644
--- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WebSafePaletteQuantizer_ErrorDither.png
+++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WebSafePaletteQuantizer_ErrorDither.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:faf061e22dd0e34c62929e9e742c279f400293b87fca15e2e6423115b3e02862
-size 290244
+oid sha256:08ace2edc5089a7742c1c8005126dcce850b1adf9c017b12db6892f4daeef1bb
+size 271721
diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WebSafePaletteQuantizer_NoDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WebSafePaletteQuantizer_NoDither.png
index bb973a0000..0205626738 100644
--- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WebSafePaletteQuantizer_NoDither.png
+++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WebSafePaletteQuantizer_NoDither.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:f9a368ff9fbb4d462a99b9eaab8e2ec81e4b1ae1d120cf5abc0cc5fe02ea941c
-size 285759
+oid sha256:3a2aae04edebcaca9b95f30963201794887fa0eac954b64c68bfe529b14fa9be
+size 269397
diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WebSafePaletteQuantizer_OrderedDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WebSafePaletteQuantizer_OrderedDither.png
index 83ae37b086..68d91fc437 100644
--- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WebSafePaletteQuantizer_OrderedDither.png
+++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WebSafePaletteQuantizer_OrderedDither.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:1926eec3a84dd8601ce0de5d8b1b70d25ebd120f4b9877b33266c18404a051fe
-size 286469
+oid sha256:2f3e9a338a5ae37c88ce0c348e0b655429220da051db3352779c277bb2dcb441
+size 270622
diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WernerPaletteQuantizer_ErrorDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WernerPaletteQuantizer_ErrorDither.png
index d3ca7f8c1c..11939c16cd 100644
--- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WernerPaletteQuantizer_ErrorDither.png
+++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WernerPaletteQuantizer_ErrorDither.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:2c45b7993e7019efae493f738d6fd441446d9ff5fdf14200003a1a8a90d67b97
-size 292334
+oid sha256:6ac7cdcc2fbee0572a369bed29c51e1c9056a4f09c4e0750ecb34d65daf403d4
+size 287741
diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WernerPaletteQuantizer_NoDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WernerPaletteQuantizer_NoDither.png
index 37181fd36d..324bd92539 100644
--- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WernerPaletteQuantizer_NoDither.png
+++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WernerPaletteQuantizer_NoDither.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:94edf1b16733a2632406f70b61bcb4f95bc9044706f63b1840cede693330814d
-size 291415
+oid sha256:752760327cc1416c171a920f1e0e95e34eae6d78bd0c7393a3be427bf3c8e55c
+size 284481
diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WernerPaletteQuantizer_OrderedDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WernerPaletteQuantizer_OrderedDither.png
index 827fc0a694..52bf2a163f 100644
--- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WernerPaletteQuantizer_OrderedDither.png
+++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WernerPaletteQuantizer_OrderedDither.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:93ac2cc58c94e036287e76cda3970f070d15c4ded5dc2e553177772d327d56f6
-size 292742
+oid sha256:293459538454e07bc9ea1e9df1fa5b0eb986fde7de42f6c25b43e4c8859bd28a
+size 285370
diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WuQuantizer_ErrorDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WuQuantizer_ErrorDither.png
index 6164b3ed6b..9702a635d8 100644
--- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WuQuantizer_ErrorDither.png
+++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WuQuantizer_ErrorDither.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:307cd34267e96ca51d82873138e319830d13743c2085788ffcdec9bf60d45671
-size 310380
+oid sha256:be7812accadc6347d6df43c308f7293596f92d0d90cf0b6a8e48fac1f4144fc0
+size 320157
diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WuQuantizer_NoDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WuQuantizer_NoDither.png
index 4981078c40..d94d57759f 100644
--- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WuQuantizer_NoDither.png
+++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WuQuantizer_NoDither.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:a8c296a49104edbd0ccb237c0333d3ab403e8ad5cc15c91f1734d2c3d78cf135
-size 309488
+oid sha256:ff094e6bafe81e818bcbac69018dcfe29366389dfca0d63d8e05ef42896ffe1d
+size 317309
diff --git a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WuQuantizer_OrderedDither.png b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WuQuantizer_OrderedDither.png
index f392f00d91..e016e3de69 100644
--- a/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WuQuantizer_OrderedDither.png
+++ b/tests/Images/External/ReferenceOutput/QuantizerTests/ApplyQuantizationInBox_CalliphoraPartial_WuQuantizer_OrderedDither.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:1874dab1b45fd976751395e1e9336ffb4d58e2e3d1643f48beea42f39245c98e
-size 311280
+oid sha256:ee0778aac671365dd0afae06cdcf8f36243bd9815f684b975f83e297bb694e63
+size 323979