|
|
|
@ -9,6 +9,7 @@ namespace ImageSharp.Quantizers |
|
|
|
using System.Buffers; |
|
|
|
using System.Numerics; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Common; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// An implementation of Wu's color quantizer with alpha channel.
|
|
|
|
@ -33,11 +34,6 @@ namespace ImageSharp.Quantizers |
|
|
|
public sealed class WuQuantizer<TColor> : IQuantizer<TColor> |
|
|
|
where TColor : struct, IPackedPixel, IEquatable<TColor> |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// The epsilon for comparing floating point numbers.
|
|
|
|
/// </summary>
|
|
|
|
private const float Epsilon = 1e-5F; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The index bits.
|
|
|
|
/// </summary>
|
|
|
|
@ -542,7 +538,7 @@ namespace ImageSharp.Quantizers |
|
|
|
|
|
|
|
double temp; |
|
|
|
|
|
|
|
if (Math.Abs(halfW) < Epsilon) |
|
|
|
if (Math.Abs(halfW) < Constants.Epsilon) |
|
|
|
{ |
|
|
|
continue; |
|
|
|
} |
|
|
|
@ -555,7 +551,7 @@ namespace ImageSharp.Quantizers |
|
|
|
halfA = wholeA - halfA; |
|
|
|
halfW = wholeW - halfW; |
|
|
|
|
|
|
|
if (Math.Abs(halfW) < Epsilon) |
|
|
|
if (Math.Abs(halfW) < Constants.Epsilon) |
|
|
|
{ |
|
|
|
continue; |
|
|
|
} |
|
|
|
@ -762,7 +758,7 @@ namespace ImageSharp.Quantizers |
|
|
|
|
|
|
|
double weight = Volume(cube[k], this.vwt); |
|
|
|
|
|
|
|
if (Math.Abs(weight) > Epsilon) |
|
|
|
if (Math.Abs(weight) > Constants.Epsilon) |
|
|
|
{ |
|
|
|
float r = (float)(Volume(cube[k], this.vmr) / weight); |
|
|
|
float g = (float)(Volume(cube[k], this.vmg) / weight); |
|
|
|
|