Class LanczosInterpolation

java.lang.Object
org.apache.sis.image.Interpolation
org.apache.sis.image.LanczosInterpolation

final class LanczosInterpolation extends Interpolation
Lanczos interpolation of arbitrary size. This interpolation is good for photographic images but not recommended for images that may contain NaN values. The Lanczos reconstruction kernel is:
L(x) = a⋅sin(π⋅x)⋅sin(π⋅x/a)/(π⋅x)² for |x| ≤ lanczos window size
Since:
1.1
Version:
1.2
See Also:
  • Field Details

    • a

      private final double a
      The Lanczos window size. This is denoted a in this class javadoc.
    • span

      private final int span
      Width of the interpolation support region.
  • Constructor Details

    • LanczosInterpolation

      LanczosInterpolation(int a)
      Creates a new interpolation.
      Parameters:
      a - the Lanczos window size.
  • Method Details

    • toString

      public String toString()
      Interpolation name for debugging purpose.
      Overrides:
      toString in class Object
    • getSupportSize

      public Dimension getSupportSize()
      Size of the area over which to provide values.
      Specified by:
      getSupportSize in class Interpolation
      Returns:
      number of sample values required for interpolations.
    • interpolate

      public void interpolate(DoubleBuffer source, int numBands, double xfrac, double yfrac, double[] writeTo, int writeToOffset)
      Applies Lanczos interpolation. Interpolation results may be outside the expected range of pixel values; caller may need to clamp.
      Specified by:
      interpolate in class Interpolation
      Parameters:
      xfrac - the X subsample position, in the [0 … 1) range except on image border.
      yfrac - the Y subsample position, in the [0 … 1) range except on image border.
      source - pixel values from the source image to use for interpolation.
      numBands - number of bands. This is the number of values to put in the writeTo array.
      writeTo - the array where this method shall write interpolated values.
      writeToOffset - index of the first value to put in the writeTo array.
    • kernel

      private double kernel(double x, double sinx)
      Computes a value of the Lanczos reconstruction kernel L(x). This is a component of Lanczos filter's kernel in two dimensions, which is L(x,y) = L(x)L(y). In this implementation, the given x value must be pre-multiplied by Math.PI.
      Note: the multiplication by π is a normalization that causes the definite integral of the function over the real numbers to equal 1.
      Parameters:
      x - must be between −a⋅π and +a⋅π inclusive.
      sinx - value of Math.sin(x).