From c3d38bac9cdcbf7732ef695d94851e0d2d81c3ba Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 27 Jun 2018 17:27:28 +1000 Subject: [PATCH] Refactor to better use base classes. --- .../ErrorDiffusionPaletteProcessor.cs | 4 +- .../OrderedDitherPaletteProcessor.cs | 4 +- .../Processors/PaletteDitherProcessorBase.cs | 28 +++++-- .../FrameQuantizerBase{TPixel}.cs | 83 +++++++++++++------ .../OctreeFrameQuantizer{TPixel}.cs | 76 +++++------------ .../PaletteFrameQuantizer{TPixel}.cs | 37 ++++++--- .../WuFrameQuantizer{TPixel}.cs | 22 +++-- .../Formats/GeneralFormatTests.cs | 35 -------- .../Processors/Dithering/DitherTests.cs | 1 - 9 files changed, 137 insertions(+), 153 deletions(-) diff --git a/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs b/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs index bad43d6c3e..19fde8487a 100644 --- a/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs +++ b/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs @@ -78,7 +78,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering.Processors // Collect the values before looping so we can reduce our calculation count for identical sibling pixels TPixel sourcePixel = source[startX, startY]; TPixel previousPixel = sourcePixel; - PixelPair pair = this.GetClosestPixelPair(ref sourcePixel, this.Palette); + PixelPair pair = this.GetClosestPixelPair(ref sourcePixel); sourcePixel.ToRgba32(ref rgba); // Convert to grayscale using ITU-R Recommendation BT.709 if required @@ -96,7 +96,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering.Processors // rather than calculating it again. This is an inexpensive optimization. if (!previousPixel.Equals(sourcePixel)) { - pair = this.GetClosestPixelPair(ref sourcePixel, this.Palette); + pair = this.GetClosestPixelPair(ref sourcePixel); // No error to spread, exact match. if (sourcePixel.Equals(pair.First)) diff --git a/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs b/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs index c41a7eec7b..32a3d290e9 100644 --- a/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs +++ b/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs @@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering.Processors // Collect the values before looping so we can reduce our calculation count for identical sibling pixels TPixel sourcePixel = source[startX, startY]; TPixel previousPixel = sourcePixel; - PixelPair pair = this.GetClosestPixelPair(ref sourcePixel, this.Palette); + PixelPair pair = this.GetClosestPixelPair(ref sourcePixel); sourcePixel.ToRgba32(ref rgba); // Convert to grayscale using ITU-R Recommendation BT.709 if required @@ -77,7 +77,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering.Processors // rather than calculating it again. This is an inexpensive optimization. if (!previousPixel.Equals(sourcePixel)) { - pair = this.GetClosestPixelPair(ref sourcePixel, this.Palette); + pair = this.GetClosestPixelPair(ref sourcePixel); // No error to spread, exact match. if (sourcePixel.Equals(pair.First)) diff --git a/src/ImageSharp/Processing/Dithering/Processors/PaletteDitherProcessorBase.cs b/src/ImageSharp/Processing/Dithering/Processors/PaletteDitherProcessorBase.cs index ed9e9bbe93..0e801e5839 100644 --- a/src/ImageSharp/Processing/Dithering/Processors/PaletteDitherProcessorBase.cs +++ b/src/ImageSharp/Processing/Dithering/Processors/PaletteDitherProcessorBase.cs @@ -18,6 +18,11 @@ namespace SixLabors.ImageSharp.Processing.Dithering.Processors { private readonly Dictionary> cache = new Dictionary>(); + /// + /// The vector representation of the image palette. + /// + private readonly Vector4[] paletteVector; + /// /// Initializes a new instance of the class. /// @@ -26,6 +31,8 @@ namespace SixLabors.ImageSharp.Processing.Dithering.Processors { Guard.NotNull(palette, nameof(palette)); this.Palette = palette; + this.paletteVector = new Vector4[this.Palette.Length]; + PixelOperations.Instance.ToScaledVector4(this.Palette, this.paletteVector, this.Palette.Length); } /// @@ -33,8 +40,13 @@ namespace SixLabors.ImageSharp.Processing.Dithering.Processors /// public TPixel[] Palette { get; } + /// + /// Returns the two closest colors from the palette calcluated via Euclidean distance in the Rgba space. + /// + /// The source color to match. + /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - protected PixelPair GetClosestPixelPair(ref TPixel pixel, TPixel[] colorPalette) + protected PixelPair GetClosestPixelPair(ref TPixel pixel) { // Check if the color is in the lookup table if (this.cache.TryGetValue(pixel, out PixelPair value)) @@ -42,11 +54,11 @@ namespace SixLabors.ImageSharp.Processing.Dithering.Processors return value; } - return this.GetClosestPixelPairSlow(ref pixel, colorPalette); + return this.GetClosestPixelPairSlow(ref pixel); } [MethodImpl(MethodImplOptions.NoInlining)] - private PixelPair GetClosestPixelPairSlow(ref TPixel pixel, TPixel[] colorPalette) + private PixelPair GetClosestPixelPairSlow(ref TPixel pixel) { // Not found - loop through the palette and find the nearest match. float leastDistance = float.MaxValue; @@ -55,21 +67,21 @@ namespace SixLabors.ImageSharp.Processing.Dithering.Processors TPixel closest = default; TPixel secondClosest = default; - for (int index = 0; index < colorPalette.Length; index++) + for (int index = 0; index < this.paletteVector.Length; index++) { - ref TPixel candidate = ref colorPalette[index]; - float distance = Vector4.DistanceSquared(vector, candidate.ToVector4()); + ref Vector4 candidate = ref this.paletteVector[index]; + float distance = Vector4.DistanceSquared(vector, candidate); if (distance < leastDistance) { leastDistance = distance; secondClosest = closest; - closest = candidate; + closest = this.Palette[index]; } else if (distance < secondLeastDistance) { secondLeastDistance = distance; - secondClosest = candidate; + secondClosest = this.Palette[index]; } } diff --git a/src/ImageSharp/Processing/Quantization/FrameQuantizers/FrameQuantizerBase{TPixel}.cs b/src/ImageSharp/Processing/Quantization/FrameQuantizers/FrameQuantizerBase{TPixel}.cs index 5153ab46b0..6637d54e01 100644 --- a/src/ImageSharp/Processing/Quantization/FrameQuantizers/FrameQuantizerBase{TPixel}.cs +++ b/src/ImageSharp/Processing/Quantization/FrameQuantizers/FrameQuantizerBase{TPixel}.cs @@ -27,6 +27,11 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers /// private readonly bool singlePass; + /// + /// The vector representation of the image palette. + /// + private Vector4[] paletteVector; + /// /// Initializes a new instance of the class. /// @@ -35,10 +40,9 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers /// If true, the quantization process only needs to loop through the source pixels once /// /// - /// If you construct this class with a true value for singlePass, then the code will, when quantizing your image, - /// only call the methods. - /// If two passes are required, the code will also call - /// and then 'QuantizeImage'. + /// If you construct this class with a true for , then the code will + /// only call the method. + /// If two passes are required, the code will also call . /// protected FrameQuantizerBase(IQuantizer quantizer, bool singlePass) { @@ -73,28 +77,31 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers } // Collect the palette. Required before the second pass runs. - var quantizedFrame = new QuantizedFrame(image.MemoryAllocator, width, height, this.GetPalette()); + TPixel[] palette = this.GetPalette(); + this.paletteVector = new Vector4[palette.Length]; + PixelOperations.Instance.ToScaledVector4(palette, this.paletteVector, palette.Length); + var quantizedFrame = new QuantizedFrame(image.MemoryAllocator, width, height, palette); if (this.Dither) { - // We clone the image as we don't want to alter the original. + // We clone the image as we don't want to alter the original via dithering. using (ImageFrame clone = image.Clone()) { - this.SecondPass(clone, quantizedFrame.GetPixelSpan(), width, height); + this.SecondPass(clone, quantizedFrame.GetPixelSpan(), palette, width, height); } } else { - this.SecondPass(image, quantizedFrame.GetPixelSpan(), width, height); + this.SecondPass(image, quantizedFrame.GetPixelSpan(), palette, width, height); } return quantizedFrame; } /// - /// Execute the first pass through the pixels in the image + /// Execute the first pass through the pixels in the image to create the palette. /// - /// The source data + /// The source data. /// The width in pixels of the image. /// The height in pixels of the image. protected virtual void FirstPass(ImageFrame source, int width, int height) @@ -102,17 +109,22 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers } /// - /// Execute a second pass through the image + /// Execute a second pass through the image to assign the pixels to a palette entry. /// /// The source image. - /// The output pixel array - /// The width in pixels of the image - /// The height in pixels of the image - protected abstract void SecondPass(ImageFrame source, Span output, int width, int height); + /// The output pixel array. + /// The output color palette. + /// The width in pixels of the image. + /// The height in pixels of the image. + protected abstract void SecondPass( + ImageFrame source, + Span output, + ReadOnlySpan palette, + int width, + int height); /// /// Retrieve the palette for the quantized image. - /// Can be called more than once so make sure calls are cached. /// /// /// @@ -120,13 +132,34 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers protected abstract TPixel[] GetPalette(); /// - /// Returns the closest color from the palette to the given color by calculating the Euclidean distance. + /// Returns the index of the first instance of the transparent color in the palette. + /// + /// The . + [MethodImpl(MethodImplOptions.AggressiveInlining)] + protected byte GetTransparentIndex() + { + // Transparent pixels are much more likely to be found at the end of a palette. + int index = this.paletteVector.Length - 1; + for (int i = this.paletteVector.Length - 1; i >= 0; i--) + { + ref Vector4 candidate = ref this.paletteVector[i]; + if (candidate.Equals(default)) + { + index = i; + } + } + + return (byte)index; + } + + /// + /// Returns the closest color from the palette to the given color by calculating the + /// Euclidean distance in the Rgba colorspace. /// /// The color. - /// The color palette. /// The [MethodImpl(MethodImplOptions.AggressiveInlining)] - protected byte GetClosestPixel(TPixel pixel, TPixel[] colorPalette) + protected byte GetClosestPixel(ref TPixel pixel) { // Check if the color is in the lookup table if (this.distanceCache.TryGetValue(pixel, out byte value)) @@ -134,22 +167,22 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers return value; } - return this.GetClosestPixelSlow(pixel, colorPalette); + return this.GetClosestPixelSlow(ref pixel); } [MethodImpl(MethodImplOptions.NoInlining)] - private byte GetClosestPixelSlow(TPixel pixel, TPixel[] colorPalette) + private byte GetClosestPixelSlow(ref TPixel pixel) { // Loop through the palette and find the nearest match. int colorIndex = 0; float leastDistance = float.MaxValue; - var vector = pixel.ToVector4(); + Vector4 vector = pixel.ToScaledVector4(); float epsilon = Constants.EpsilonSquared; - for (int index = 0; index < colorPalette.Length; index++) + for (int index = 0; index < this.paletteVector.Length; index++) { - ref TPixel candidate = ref colorPalette[index]; - float distance = Vector4.DistanceSquared(vector, candidate.ToVector4()); + ref Vector4 candidate = ref this.paletteVector[index]; + float distance = Vector4.DistanceSquared(vector, candidate); // Greater... Move on. if (!(distance < leastDistance)) diff --git a/src/ImageSharp/Processing/Quantization/FrameQuantizers/OctreeFrameQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Quantization/FrameQuantizers/OctreeFrameQuantizer{TPixel}.cs index fb68c2148d..d733733958 100644 --- a/src/ImageSharp/Processing/Quantization/FrameQuantizers/OctreeFrameQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Quantization/FrameQuantizers/OctreeFrameQuantizer{TPixel}.cs @@ -29,11 +29,6 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers /// private readonly Octree octree; - /// - /// The reduced image palette - /// - private TPixel[] palette; - /// /// The transparent index /// @@ -77,16 +72,21 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers } /// - protected override void SecondPass(ImageFrame source, Span output, int width, int height) + protected override void SecondPass( + ImageFrame source, + Span output, + ReadOnlySpan palette, + int width, + int height) { // Load up the values for the first pixel. We can use these to speed up the second // pass of the algorithm by avoiding transforming rows of identical color. TPixel sourcePixel = source[0, 0]; TPixel previousPixel = sourcePixel; Rgba32 rgba = default; - byte pixelValue = this.QuantizePixel(sourcePixel, ref rgba); - TPixel[] colorPalette = this.GetPalette(); - TPixel transformedPixel = colorPalette[pixelValue]; + this.transparentIndex = this.GetTransparentIndex(); + byte pixelValue = this.QuantizePixel(ref sourcePixel, ref rgba); + TPixel transformedPixel = palette[pixelValue]; for (int y = 0; y < height; y++) { @@ -103,14 +103,14 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers if (!previousPixel.Equals(sourcePixel)) { // Quantize the pixel - pixelValue = this.QuantizePixel(sourcePixel, ref rgba); + pixelValue = this.QuantizePixel(ref sourcePixel, ref rgba); // And setup the previous pointer previousPixel = sourcePixel; if (this.Dither) { - transformedPixel = colorPalette[pixelValue]; + transformedPixel = palette[pixelValue]; } } @@ -126,58 +126,22 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers } /// - protected override TPixel[] GetPalette() - { - if (this.palette == null) - { - this.palette = this.octree.Palletize(Math.Max(this.colors, (byte)1)); - this.transparentIndex = this.GetTransparentIndex(); - } - - return this.palette; - } - - /// - /// Returns the index of the first instance of the transparent color in the palette. - /// - /// - /// The . - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private byte GetTransparentIndex() - { - // Transparent pixels are much more likely to be found at the end of a palette - int index = this.colors; - Rgba32 trans = default; - for (int i = this.palette.Length - 1; i >= 0; i--) - { - this.palette[i].ToRgba32(ref trans); - - if (trans.Equals(default)) - { - index = i; - } - } - - return (byte)index; - } + protected override TPixel[] GetPalette() => this.octree.Palletize(this.colors); /// - /// Process the pixel in the second pass of the algorithm + /// Process the pixel in the second pass of the algorithm. /// - /// The pixel to quantize - /// The color to compare against - /// - /// The quantized value - /// + /// The pixel to quantize. + /// The color to compare against. + /// The [MethodImpl(MethodImplOptions.AggressiveInlining)] - private byte QuantizePixel(TPixel pixel, ref Rgba32 rgba) + private byte QuantizePixel(ref TPixel pixel, ref Rgba32 rgba) { if (this.Dither) { - // The colors have changed so we need to use Euclidean distance calculation to find the closest value. - // This palette can never be null here. - return this.GetClosestPixel(pixel, this.palette); + // The colors have changed so we need to use Euclidean distance calculation to + // find the closest value. + return this.GetClosestPixel(ref pixel); } pixel.ToRgba32(ref rgba); diff --git a/src/ImageSharp/Processing/Quantization/FrameQuantizers/PaletteFrameQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Quantization/FrameQuantizers/PaletteFrameQuantizer{TPixel}.cs index 3e5cea5c8d..cb72626d5e 100644 --- a/src/ImageSharp/Processing/Quantization/FrameQuantizers/PaletteFrameQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Quantization/FrameQuantizers/PaletteFrameQuantizer{TPixel}.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. using System; +using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using SixLabors.ImageSharp.Advanced; @@ -18,9 +19,14 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers where TPixel : struct, IPixel { /// - /// List of all colors in the palette. + /// The reduced image palette. /// - private readonly TPixel[] colors; + private readonly TPixel[] palette; + + /// + /// The vector representation of the image palette. + /// + private readonly Vector4[] paletteVector; /// /// Initializes a new instance of the class. @@ -30,20 +36,27 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers public PaletteFrameQuantizer(PaletteQuantizer quantizer, TPixel[] colors) : base(quantizer, true) { - Guard.MustBeBetweenOrEqualTo(colors.Length, 1, 255, nameof(colors)); - this.colors = colors; + Guard.MustBeBetweenOrEqualTo(colors.Length, 1, 256, nameof(colors)); + this.palette = colors; + this.paletteVector = new Vector4[this.palette.Length]; + PixelOperations.Instance.ToScaledVector4(this.palette, this.paletteVector, this.palette.Length); } /// - protected override void SecondPass(ImageFrame source, Span output, int width, int height) + protected override void SecondPass( + ImageFrame source, + Span output, + ReadOnlySpan palette, + int width, + int height) { // Load up the values for the first pixel. We can use these to speed up the second // pass of the algorithm by avoiding transforming rows of identical color. TPixel sourcePixel = source[0, 0]; TPixel previousPixel = sourcePixel; - byte pixelValue = this.QuantizePixel(sourcePixel); - ref TPixel colorPaletteRef = ref MemoryMarshal.GetReference(this.GetPalette().AsSpan()); - TPixel transformedPixel = Unsafe.Add(ref colorPaletteRef, pixelValue); + byte pixelValue = this.QuantizePixel(ref sourcePixel); + ref TPixel paletteRef = ref MemoryMarshal.GetReference(palette); + TPixel transformedPixel = Unsafe.Add(ref paletteRef, pixelValue); for (int y = 0; y < height; y++) { @@ -60,14 +73,14 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers if (!previousPixel.Equals(sourcePixel)) { // Quantize the pixel - pixelValue = this.QuantizePixel(sourcePixel); + pixelValue = this.QuantizePixel(ref sourcePixel); // And setup the previous pointer previousPixel = sourcePixel; if (this.Dither) { - transformedPixel = Unsafe.Add(ref colorPaletteRef, pixelValue); + transformedPixel = Unsafe.Add(ref paletteRef, pixelValue); } } @@ -84,7 +97,7 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - protected override TPixel[] GetPalette() => this.colors; + protected override TPixel[] GetPalette() => this.palette; /// /// Process the pixel in the second pass of the algorithm @@ -94,6 +107,6 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers /// The quantized value /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - private byte QuantizePixel(TPixel pixel) => this.GetClosestPixel(pixel, this.GetPalette()); + private byte QuantizePixel(ref TPixel pixel) => this.GetClosestPixel(ref pixel); } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Quantization/FrameQuantizers/WuFrameQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Quantization/FrameQuantizers/WuFrameQuantizer{TPixel}.cs index 3cf9658153..cb8721d063 100644 --- a/src/ImageSharp/Processing/Quantization/FrameQuantizers/WuFrameQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Quantization/FrameQuantizers/WuFrameQuantizer{TPixel}.cs @@ -39,7 +39,6 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers // - Do we really need to ALWAYS allocate the whole table of size TableLength? (~ 2471625 * sizeof(long) * 5 bytes ) // - Isn't an AOS ("array of structures") layout more efficient & more readable than SOA ("structure of arrays") for this particular use case? // (T, R, G, B, A, M2) could be grouped together! - // - There are per-pixel virtual calls in InitialQuantizePixel, why not do it on a per-row basis? // - It's a frequently used class, we need tests! (So we can optimize safely.) There are tests in the original!!! We should just adopt them! // https://github.com/JeremyAnsel/JeremyAnsel.ColorQuant/blob/master/JeremyAnsel.ColorQuant/JeremyAnsel.ColorQuant.Tests/WuColorQuantizerTests.cs @@ -182,7 +181,7 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers float a = Volume(ref this.colorCube[k], this.vma.GetSpan()); ref TPixel color = ref this.palette[k]; - color.PackFromVector4(new Vector4(r, g, b, a) / weight / 255F); + color.PackFromScaledVector4(new Vector4(r, g, b, a) / weight / 255F); } } } @@ -246,15 +245,14 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers } /// - protected override void SecondPass(ImageFrame source, Span output, int width, int height) + protected override void SecondPass(ImageFrame source, Span output, ReadOnlySpan palette, int width, int height) { // Load up the values for the first pixel. We can use these to speed up the second // pass of the algorithm by avoiding transforming rows of identical color. TPixel sourcePixel = source[0, 0]; TPixel previousPixel = sourcePixel; - byte pixelValue = this.QuantizePixel(sourcePixel); - TPixel[] colorPalette = this.GetPalette(); - TPixel transformedPixel = colorPalette[pixelValue]; + byte pixelValue = this.QuantizePixel(ref sourcePixel); + TPixel transformedPixel = palette[pixelValue]; for (int y = 0; y < height; y++) { @@ -271,14 +269,14 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers if (!previousPixel.Equals(sourcePixel)) { // Quantize the pixel - pixelValue = this.QuantizePixel(sourcePixel); + pixelValue = this.QuantizePixel(ref sourcePixel); // And setup the previous pointer previousPixel = sourcePixel; if (this.Dither) { - transformedPixel = colorPalette[pixelValue]; + transformedPixel = palette[pixelValue]; } } @@ -843,13 +841,13 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers /// The quantized value /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - private byte QuantizePixel(TPixel pixel) + private byte QuantizePixel(ref TPixel pixel) { if (this.Dither) { - // The colors have changed so we need to use Euclidean distance calculation to find the closest value. - // This palette can never be null here. - return this.GetClosestPixel(pixel, this.palette); + // The colors have changed so we need to use Euclidean distance calculation to + // find the closest value. + return this.GetClosestPixel(ref pixel); } // Expected order r->g->b->a diff --git a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs index 5180945362..cd3b72e27b 100644 --- a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs +++ b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs @@ -87,41 +87,6 @@ namespace SixLabors.ImageSharp.Tests } provider.Configuration.MemoryAllocator.ReleaseRetainedResources(); - - //string path = TestEnvironment.CreateOutputDirectory("Quantize"); - - //foreach (TestFile file in Files) - //{ - // using (Image srcImage = Image.Load(file.Bytes, out IImageFormat mimeType)) - // { - // using (Image image = srcImage.Clone()) - // { - // using (FileStream output = File.OpenWrite($"{path}/Octree-{file.FileName}")) - // { - // image.Mutate(x => x.Quantize(KnownQuantizers.Octree)); - // image.Save(output, mimeType); - // } - // } - - // using (Image image = srcImage.Clone()) - // { - // using (FileStream output = File.OpenWrite($"{path}/Wu-{file.FileName}")) - // { - // image.Mutate(x => x.Quantize(KnownQuantizers.Wu)); - // image.Save(output, mimeType); - // } - // } - - // using (Image image = srcImage.Clone()) - // { - // using (FileStream output = File.OpenWrite($"{path}/Palette-{file.FileName}")) - // { - // image.Mutate(x => x.Quantize(KnownQuantizers.Palette)); - // image.Save(output, mimeType); - // } - // } - // } - //} } private static IQuantizer GetQuantizer(string name) diff --git a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs index 24cb87c7fc..ba31e35a23 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs @@ -40,7 +40,6 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization { "Stucki", KnownDiffusers.Stucki }, }; - private static IOrderedDither DefaultDitherer => KnownDitherers.BayerDither4x4; private static IErrorDiffuser DefaultErrorDiffuser => KnownDiffusers.Atkinson;