Package org.apache.sis.image
Class LanczosInterpolation
java.lang.Object
org.apache.sis.image.Interpolation
org.apache.sis.image.LanczosInterpolation
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final double
The Lanczos window size.private final int
Width of the interpolation support region.Fields inherited from class org.apache.sis.image.Interpolation
BILINEAR, LANCZOS, NEAREST
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSize of the area over which to provide values.void
interpolate
(DoubleBuffer source, int numBands, double xfrac, double yfrac, double[] writeTo, int writeToOffset) Applies Lanczos interpolation.private double
kernel
(double x, double sinx) Computes a value of the Lanczos reconstruction kernel L(x).toString()
Interpolation name for debugging purpose.Methods inherited from class org.apache.sis.image.Interpolation
toCompatible
-
Field Details
-
a
private final double aThe Lanczos window size. This is denoted a in this class javadoc. -
span
private final int spanWidth of the interpolation support region.
-
-
Constructor Details
-
LanczosInterpolation
LanczosInterpolation(int a) Creates a new interpolation.- Parameters:
a
- the Lanczos window size.
-
-
Method Details
-
toString
Interpolation name for debugging purpose. -
getSupportSize
Size of the area over which to provide values.- Specified by:
getSupportSize
in classInterpolation
- 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 classInterpolation
- 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 thewriteTo
array.writeTo
- the array where this method shall write interpolated values.writeToOffset
- index of the first value to put in thewriteTo
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 byMath.PI
.Note: the multiplication by π is a normalization that causes the definite integral of the function over the real numbers to equal 1.
-