Browse Source

Add Lanczos5

Former-commit-id: dd83c793aea242e533c04f1ed0526319e3608c7b
Former-commit-id: 27cfda9e96a3148eb9345992050880cfa830dbd5
Former-commit-id: 4d4eb638fed3de06a05eca59d161acdd2d389b7f
af/merge-core
James Jackson-South 10 years ago
parent
commit
7eb70c0d2b
  1. 33
      src/ImageProcessor/Samplers/Resamplers/Lanczos5Resampler.cs
  2. 1
      tests/ImageProcessor.Tests/Processors/Samplers/SamplerTests.cs

33
src/ImageProcessor/Samplers/Resamplers/Lanczos5Resampler.cs

@ -0,0 +1,33 @@
// <copyright file="Lanczos5Resampler.cs" company="James South">
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageProcessor.Samplers
{
/// <summary>
/// The function implements the Lanczos kernel algorithm as described on
/// <see href="https://en.wikipedia.org/wiki/Lanczos_resampling#Algorithm">Wikipedia</see>
/// </summary>
public class Lanczos5Resampler : IResampler
{
/// <inheritdoc/>
public double Radius => 5;
/// <inheritdoc/>
public double GetValue(double x)
{
if (x < 0)
{
x = -x;
}
if (x < 5)
{
return ImageMaths.SinC(x) * ImageMaths.SinC(x / 5f);
}
return 0;
}
}
}

1
tests/ImageProcessor.Tests/Processors/Samplers/SamplerTests.cs

@ -17,6 +17,7 @@ namespace ImageProcessor.Tests
{ "Triangle", new TriangleResampler() },
{ "Box", new BoxResampler() },
{ "Lanczos3", new Lanczos3Resampler() },
{ "Lanczos5", new Lanczos5Resampler() },
{ "Lanczos8", new Lanczos8Resampler() },
{ "MitchellNetravali", new MitchellNetravaliResampler() },
{ "Hermite", new HermiteResampler() },

Loading…
Cancel
Save