org.openimaj.math.util

## Class Interpolation

• ```public class Interpolation
extends Object```
Static methods for performing interpolation
Author:
Jonathon Hare (jsh2@ecs.soton.ac.uk)
• ### Constructor Summary

Constructors
Constructor and Description
`Interpolation()`
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static double` ```bicubicInterp(double x, double y, double[][] p)```
Bicubic interpolation of the value at x,y where 0<=x<=1 and 0<=y<=1 given the values at integer coordinates from (-1,-1) to (3,3).
`static float` ```bicubicInterp(float x, float y, float[][] p)```
Bicubic interpolation of the value at x,y where 0<=x<=1 and 0<=y<=1 given the values at integer coordinates from (-1,-1) to (3,3).
`static double` ```bilerp(double x, double y, double f00, double f01, double f10, double f11)```
Bilinear interpolation of the value at x,y where 0<=x<=1 and 0<=y<=1 given the values at (0,0), (0,1), (1,0) and (1,1).
`static float` ```bilerp(float x, float y, float f00, float f01, float f10, float f11)```
Bilinear interpolation of the value at x,y where 0<=x<=1 and 0<=y<=1 given the values at (0,0), (0,1), (1,0) and (1,1).
`static float` ```bilerpf(float x, float y, float f00, float f01, float f10, float f11)```
Bilinear interpolation of the value at x,y where 0<=x<=1 and 0<=y<=1 given the values at (0,0), (0,1), (1,0) and (1,1).
`static double` ```cubicInterp(double x, double[] y)```
Cubic interpolation of y at x (in 0..1) given y at x=[-1, 0, 1, 2]
`static double` ```cubicInterp(double x, double y0, double y1, double y2, double y3)```
Cubic interpolation of y at x (in 0..1) given y at x=[-1, 0, 1, 2]
`static float` ```cubicInterp(float x, float[] y)```
Cubic interpolation of y at x (in 0..1) given y at x=[-1, 0, 1, 2]
`static float` ```cubicInterp(float x, float y0, float y1, float y2, float y3)```
Cubic interpolation of y at x (in 0..1) given y at x=[-1, 0, 1, 2]
`static double` ```lerp(double x, double x0, double y0, double x1, double y1)```
Linear interpolation of y at x given x0,y0 and x1,y1.
`static float` ```lerp(float x, float x0, float y0, float x1, float y1)```
Linear interpolation of y at x given x0,y0 and x1,y1.
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Constructor Detail

• #### Interpolation

`public Interpolation()`
• ### Method Detail

• #### lerp

```public static float lerp(float x,
float x0,
float y0,
float x1,
float y1)```
Linear interpolation of y at x given x0,y0 and x1,y1.
Parameters:
`x` - the x position
`x0` - the first x position
`y0` - the first y position
`x1` - the second x position
`y1` - the second y position
Returns:
the interpolated value (y) at x
• #### lerp

```public static double lerp(double x,
double x0,
double y0,
double x1,
double y1)```
Linear interpolation of y at x given x0,y0 and x1,y1.
Parameters:
`x` - the x position
`x0` - the first x position
`y0` - the first y position
`x1` - the second x position
`y1` - the second y position
Returns:
the interpolated value (y) at x
• #### cubicInterp

```public static double cubicInterp(double x,
double y0,
double y1,
double y2,
double y3)```
Cubic interpolation of y at x (in 0..1) given y at x=[-1, 0, 1, 2]
Parameters:
`x` - the x value to compute
`y0` - y value at x=-1
`y1` - y value at x=0
`y2` - y value at x=1
`y3` - y value at x=2
Returns:
the interpolated value
• #### cubicInterp

```public static float cubicInterp(float x,
float y0,
float y1,
float y2,
float y3)```
Cubic interpolation of y at x (in 0..1) given y at x=[-1, 0, 1, 2]
Parameters:
`x` - the x value to compute
`y0` - y value at x=-1
`y1` - y value at x=0
`y2` - y value at x=1
`y3` - y value at x=2
Returns:
the interpolated value
• #### cubicInterp

```public static double cubicInterp(double x,
double[] y)```
Cubic interpolation of y at x (in 0..1) given y at x=[-1, 0, 1, 2]
Parameters:
`x` - the x value to compute
`y` - an array of 4 y values at x=[-1, 0, 1, 2]
Returns:
the interpolated value
• #### cubicInterp

```public static float cubicInterp(float x,
float[] y)```
Cubic interpolation of y at x (in 0..1) given y at x=[-1, 0, 1, 2]
Parameters:
`x` - the x value to compute
`y` - an array of 4 y values at x=[-1, 0, 1, 2]
Returns:
the interpolated value
• #### bilerp

```public static double bilerp(double x,
double y,
double f00,
double f01,
double f10,
double f11)```
Bilinear interpolation of the value at x,y where 0<=x<=1 and 0<=y<=1 given the values at (0,0), (0,1), (1,0) and (1,1). Note: This will work for other values of (x,y) but doesn't normally make sense.
Parameters:
`x` - the x position (in 0..1)
`y` - the y position (in 0..1)
`f00` - the value at (0,0)
`f01` - the value at (0,1)
`f10` - the value at (1,0)
`f11` - the value at (1,1)
Returns:
the interpolated value (x,y)
• #### bilerpf

```public static float bilerpf(float x,
float y,
float f00,
float f01,
float f10,
float f11)```
Bilinear interpolation of the value at x,y where 0<=x<=1 and 0<=y<=1 given the values at (0,0), (0,1), (1,0) and (1,1). Note: This will work for other values of (x,y) but doesn't normally make sense.
Parameters:
`x` - the x position (in 0..1)
`y` - the y position (in 0..1)
`f00` - the value at (0,0)
`f01` - the value at (0,1)
`f10` - the value at (1,0)
`f11` - the value at (1,1)
Returns:
the interpolated value (x,y)
• #### bilerp

```public static float bilerp(float x,
float y,
float f00,
float f01,
float f10,
float f11)```
Bilinear interpolation of the value at x,y where 0<=x<=1 and 0<=y<=1 given the values at (0,0), (0,1), (1,0) and (1,1). Note: This will work for other values of (x,y) but doesn't normally make sense.
Parameters:
`x` - the x position (in 0..1)
`y` - the y position (in 0..1)
`f00` - the value at (0,0)
`f01` - the value at (0,1)
`f10` - the value at (1,0)
`f11` - the value at (1,1)
Returns:
the interpolated value (x,y)
• #### bicubicInterp

```public static double bicubicInterp(double x,
double y,
double[][] p)```
Bicubic interpolation of the value at x,y where 0<=x<=1 and 0<=y<=1 given the values at integer coordinates from (-1,-1) to (3,3).
Parameters:
`x` - the x position (in 0..1)
`y` - the y position (in 0..1)
`p` - a 4x4 array of known values at (-1,-1) to (3,3)
Returns:
the interpolated value (x,y)
• #### bicubicInterp

```public static float bicubicInterp(float x,
float y,
float[][] p)```
Bicubic interpolation of the value at x,y where 0<=x<=1 and 0<=y<=1 given the values at integer coordinates from (-1,-1) to (3,3).
Parameters:
`x` - the x position (in 0..1)
`y` - the y position (in 0..1)
`p` - a 4x4 array of known values at (-1,-1) to (3,3)
Returns:
the interpolated value (x,y)