Browse Source

Suffix dither and diffusion classes

pull/299/head
James Jackson-South 9 years ago
parent
commit
57df369934
  1. 6
      src/ImageSharp/Dithering/ErrorDiffusion/AtkinsonDiffuser.cs
  2. 6
      src/ImageSharp/Dithering/ErrorDiffusion/BurksDiffuser.cs
  3. 6
      src/ImageSharp/Dithering/ErrorDiffusion/FloydSteinbergDiffuser.cs
  4. 6
      src/ImageSharp/Dithering/ErrorDiffusion/JarvisJudiceNinkeDiffuser.cs
  5. 6
      src/ImageSharp/Dithering/ErrorDiffusion/Sierra2Diffuser.cs
  6. 6
      src/ImageSharp/Dithering/ErrorDiffusion/Sierra3Diffuser.cs
  7. 6
      src/ImageSharp/Dithering/ErrorDiffusion/SierraLiteDiffuser.cs
  8. 6
      src/ImageSharp/Dithering/ErrorDiffusion/StuckiDiffuser.cs
  9. 6
      src/ImageSharp/Dithering/Ordered/BayerDither.cs
  10. 6
      src/ImageSharp/Dithering/Ordered/OrderedDither.cs
  11. 2
      src/ImageSharp/Quantizers/Quantizer{TPixel}.cs
  12. 24
      tests/ImageSharp.Tests/Processing/Processors/Binarization/DitherTests.cs

6
src/ImageSharp/Dithering/ErrorDiffusion/Atkinson.cs → src/ImageSharp/Dithering/ErrorDiffusion/AtkinsonDiffuser.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Dithering
/// Applies error diffusion based dithering using the Atkinson image dithering algorithm.
/// <see href="http://www.efg2.com/Lab/Library/ImageProcessing/DHALF.TXT"/>
/// </summary>
public sealed class Atkinson : ErrorDiffuser
public sealed class AtkinsonDiffuser : ErrorDiffuser
{
/// <summary>
/// The diffusion matrix
@ -23,9 +23,9 @@ namespace SixLabors.ImageSharp.Dithering
};
/// <summary>
/// Initializes a new instance of the <see cref="Atkinson"/> class.
/// Initializes a new instance of the <see cref="AtkinsonDiffuser"/> class.
/// </summary>
public Atkinson()
public AtkinsonDiffuser()
: base(AtkinsonMatrix, 8)
{
}

6
src/ImageSharp/Dithering/ErrorDiffusion/Burks.cs → src/ImageSharp/Dithering/ErrorDiffusion/BurksDiffuser.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Dithering
/// Applies error diffusion based dithering using the Burks image dithering algorithm.
/// <see href="http://www.efg2.com/Lab/Library/ImageProcessing/DHALF.TXT"/>
/// </summary>
public sealed class Burks : ErrorDiffuser
public sealed class BurksDiffuser : ErrorDiffuser
{
/// <summary>
/// The diffusion matrix
@ -22,9 +22,9 @@ namespace SixLabors.ImageSharp.Dithering
};
/// <summary>
/// Initializes a new instance of the <see cref="Burks"/> class.
/// Initializes a new instance of the <see cref="BurksDiffuser"/> class.
/// </summary>
public Burks()
public BurksDiffuser()
: base(BurksMatrix, 32)
{
}

6
src/ImageSharp/Dithering/ErrorDiffusion/FloydSteinberg.cs → src/ImageSharp/Dithering/ErrorDiffusion/FloydSteinbergDiffuser.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Dithering
/// Applies error diffusion based dithering using the Floyd–Steinberg image dithering algorithm.
/// <see href="http://www.efg2.com/Lab/Library/ImageProcessing/DHALF.TXT"/>
/// </summary>
public sealed class FloydSteinberg : ErrorDiffuser
public sealed class FloydSteinbergDiffuser : ErrorDiffuser
{
/// <summary>
/// The diffusion matrix
@ -22,9 +22,9 @@ namespace SixLabors.ImageSharp.Dithering
};
/// <summary>
/// Initializes a new instance of the <see cref="FloydSteinberg"/> class.
/// Initializes a new instance of the <see cref="FloydSteinbergDiffuser"/> class.
/// </summary>
public FloydSteinberg()
public FloydSteinbergDiffuser()
: base(FloydSteinbergMatrix, 16)
{
}

6
src/ImageSharp/Dithering/ErrorDiffusion/JarvisJudiceNinke.cs → src/ImageSharp/Dithering/ErrorDiffusion/JarvisJudiceNinkeDiffuser.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Dithering
/// Applies error diffusion based dithering using the JarvisJudiceNinke image dithering algorithm.
/// <see href="http://www.efg2.com/Lab/Library/ImageProcessing/DHALF.TXT"/>
/// </summary>
public sealed class JarvisJudiceNinke : ErrorDiffuser
public sealed class JarvisJudiceNinkeDiffuser : ErrorDiffuser
{
/// <summary>
/// The diffusion matrix
@ -23,9 +23,9 @@ namespace SixLabors.ImageSharp.Dithering
};
/// <summary>
/// Initializes a new instance of the <see cref="JarvisJudiceNinke"/> class.
/// Initializes a new instance of the <see cref="JarvisJudiceNinkeDiffuser"/> class.
/// </summary>
public JarvisJudiceNinke()
public JarvisJudiceNinkeDiffuser()
: base(JarvisJudiceNinkeMatrix, 48)
{
}

6
src/ImageSharp/Dithering/ErrorDiffusion/Sierra2.cs → src/ImageSharp/Dithering/ErrorDiffusion/Sierra2Diffuser.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Dithering
/// Applies error diffusion based dithering using the Sierra2 image dithering algorithm.
/// <see href="http://www.efg2.com/Lab/Library/ImageProcessing/DHALF.TXT"/>
/// </summary>
public sealed class Sierra2 : ErrorDiffuser
public sealed class Sierra2Diffuser : ErrorDiffuser
{
/// <summary>
/// The diffusion matrix
@ -22,9 +22,9 @@ namespace SixLabors.ImageSharp.Dithering
};
/// <summary>
/// Initializes a new instance of the <see cref="Sierra2"/> class.
/// Initializes a new instance of the <see cref="Sierra2Diffuser"/> class.
/// </summary>
public Sierra2()
public Sierra2Diffuser()
: base(Sierra2Matrix, 16)
{
}

6
src/ImageSharp/Dithering/ErrorDiffusion/Sierra3.cs → src/ImageSharp/Dithering/ErrorDiffusion/Sierra3Diffuser.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Dithering
/// Applies error diffusion based dithering using the Sierra3 image dithering algorithm.
/// <see href="http://www.efg2.com/Lab/Library/ImageProcessing/DHALF.TXT"/>
/// </summary>
public sealed class Sierra3 : ErrorDiffuser
public sealed class Sierra3Diffuser : ErrorDiffuser
{
/// <summary>
/// The diffusion matrix
@ -23,9 +23,9 @@ namespace SixLabors.ImageSharp.Dithering
};
/// <summary>
/// Initializes a new instance of the <see cref="Sierra3"/> class.
/// Initializes a new instance of the <see cref="Sierra3Diffuser"/> class.
/// </summary>
public Sierra3()
public Sierra3Diffuser()
: base(Sierra3Matrix, 32)
{
}

6
src/ImageSharp/Dithering/ErrorDiffusion/SierraLite.cs → src/ImageSharp/Dithering/ErrorDiffusion/SierraLiteDiffuser.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Dithering
/// Applies error diffusion based dithering using the SierraLite image dithering algorithm.
/// <see href="http://www.efg2.com/Lab/Library/ImageProcessing/DHALF.TXT"/>
/// </summary>
public sealed class SierraLite : ErrorDiffuser
public sealed class SierraLiteDiffuser : ErrorDiffuser
{
/// <summary>
/// The diffusion matrix
@ -22,9 +22,9 @@ namespace SixLabors.ImageSharp.Dithering
};
/// <summary>
/// Initializes a new instance of the <see cref="SierraLite"/> class.
/// Initializes a new instance of the <see cref="SierraLiteDiffuser"/> class.
/// </summary>
public SierraLite()
public SierraLiteDiffuser()
: base(SierraLiteMatrix, 4)
{
}

6
src/ImageSharp/Dithering/ErrorDiffusion/Stucki.cs → src/ImageSharp/Dithering/ErrorDiffusion/StuckiDiffuser.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Dithering
/// Applies error diffusion based dithering using the Stucki image dithering algorithm.
/// <see href="http://www.efg2.com/Lab/Library/ImageProcessing/DHALF.TXT"/>
/// </summary>
public sealed class Stucki : ErrorDiffuser
public sealed class StuckiDiffuser : ErrorDiffuser
{
/// <summary>
/// The diffusion matrix
@ -23,9 +23,9 @@ namespace SixLabors.ImageSharp.Dithering
};
/// <summary>
/// Initializes a new instance of the <see cref="Stucki"/> class.
/// Initializes a new instance of the <see cref="StuckiDiffuser"/> class.
/// </summary>
public Stucki()
public StuckiDiffuser()
: base(StuckiMatrix, 42)
{
}

6
src/ImageSharp/Dithering/Ordered/Bayer.cs → src/ImageSharp/Dithering/Ordered/BayerDither.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Dithering.Ordered
/// Applies error diffusion based dithering using the 4x4 Bayer dithering matrix.
/// <see href="http://www.efg2.com/Lab/Library/ImageProcessing/DHALF.TXT"/>
/// </summary>
public sealed class Bayer : OrderedDither4x4
public sealed class BayerDither : OrderedDither4x4
{
/// <summary>
/// The threshold matrix.
@ -25,9 +25,9 @@ namespace SixLabors.ImageSharp.Dithering.Ordered
};
/// <summary>
/// Initializes a new instance of the <see cref="Bayer"/> class.
/// Initializes a new instance of the <see cref="BayerDither"/> class.
/// </summary>
public Bayer()
public BayerDither()
: base(ThresholdMatrix)
{
}

6
src/ImageSharp/Dithering/Ordered/Ordered.cs → src/ImageSharp/Dithering/Ordered/OrderedDither.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Dithering.Ordered
/// Applies error diffusion based dithering using the 4x4 ordered dithering matrix.
/// <see href="https://en.wikipedia.org/wiki/Ordered_dithering"/>
/// </summary>
public sealed class Ordered : OrderedDither4x4
public sealed class OrderedDither : OrderedDither4x4
{
/// <summary>
/// The threshold matrix.
@ -25,9 +25,9 @@ namespace SixLabors.ImageSharp.Dithering.Ordered
};
/// <summary>
/// Initializes a new instance of the <see cref="Ordered"/> class.
/// Initializes a new instance of the <see cref="OrderedDither"/> class.
/// </summary>
public Ordered()
public OrderedDither()
: base(ThresholdMatrix)
{
}

2
src/ImageSharp/Quantizers/Quantizer{TPixel}.cs

@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Quantizers
public bool Dither { get; set; } = true;
/// <inheritdoc />
public IErrorDiffuser DitherType { get; set; } = new SierraLite();
public IErrorDiffuser DitherType { get; set; } = new SierraLiteDiffuser();
/// <inheritdoc/>
public virtual QuantizedImage<TPixel> Quantize(ImageBase<TPixel> image, int maxColors)

24
tests/ImageSharp.Tests/Processing/Processors/Binarization/DitherTests.cs

@ -23,26 +23,26 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization
public static readonly TheoryData<string, IOrderedDither> Ditherers = new TheoryData<string, IOrderedDither>
{
{ "Ordered", new Ordered() },
{ "Bayer", new Bayer() }
{ "Ordered", new OrderedDither() },
{ "Bayer", new BayerDither() }
};
public static readonly TheoryData<string, IErrorDiffuser> ErrorDiffusers = new TheoryData<string, IErrorDiffuser>
{
{ "Atkinson", new Atkinson() },
{ "Burks", new Burks() },
{ "FloydSteinberg", new FloydSteinberg() },
{ "JarvisJudiceNinke", new JarvisJudiceNinke() },
{ "Sierra2", new Sierra2() },
{ "Sierra3", new Sierra3() },
{ "SierraLite", new SierraLite() },
{ "Stucki", new Stucki() },
{ "Atkinson", new AtkinsonDiffuser() },
{ "Burks", new BurksDiffuser() },
{ "FloydSteinberg", new FloydSteinbergDiffuser() },
{ "JarvisJudiceNinke", new JarvisJudiceNinkeDiffuser() },
{ "Sierra2", new Sierra2Diffuser() },
{ "Sierra3", new Sierra3Diffuser() },
{ "SierraLite", new SierraLiteDiffuser() },
{ "Stucki", new StuckiDiffuser() },
};
private static IOrderedDither DefaultDitherer => new Ordered();
private static IOrderedDither DefaultDitherer => new OrderedDither();
private static IErrorDiffuser DefaultErrorDiffuser => new Atkinson();
private static IErrorDiffuser DefaultErrorDiffuser => new AtkinsonDiffuser();
[Theory]
[WithFileCollection(nameof(CommonTestImages), nameof(Ditherers), DefaultPixelType)]

Loading…
Cancel
Save