math

## Class BSpline

• ```public class BSpline
extends Object```
This class implements basic operations to work with cubic B-splines.
Author:
Ignacio Arganda-Carreras - ignacio.arganda@gmail.com
• ### Constructor Summary

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

All Methods
Modifier and Type Method and Description
`static double[]` ```convertToInterpCoef(double[] input, double[] poles, double tolerance)```
Convert to interpolation coefficients
`static double[]` ```convertToSamples(double[] coef, double[] samples)```
Convert the spline coefficients to samples
`static int` `factorial(int n)`
Factorial
`static double[]` `finDiffAS(double[] c)`
Finite Difference.
`static double` ```initialAntiCausalCoefficient(double[] c, double z)```
Get initial anti-causal coefficients
`static double` ```initialCausalCoefficient(double[] c, double z, double tolerance)```
Initialization of causal coefficients for mirror boundary conditions
`static double[]` `integAS(double[] c)`
Begin computation of the running sums.
`static double` ```integSA(double[] c, double[] z)```
Begin computation of the running sums.
`static double` `mean(double[] A)`
Calculate mean value on the period (2*length(A)-2)
`static double[]` ```resampling(double[] input, int nInput, int nOut, double scale, int n1, int nt)```
Geometric transform and resampling
`static double[]` ```resize1D(double[] input, int n, int n1, int n2, double scale, boolean coefOrSamples)```
Ref: A.
`static double[]` `tableOfPoles(int splineDegree)`
Recover the poles from a lookup table
`static double[]` `tableOfSamples(int splineDegree)`
Recover the B-spline samples values from a lookup table
• ### Methods inherited from class java.lang.Object

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

• #### BSpline

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

• #### resize1D

```public static double[] resize1D(double[] input,
int n,
int n1,
int n2,
double scale,
boolean coefOrSamples)```

Ref: A. MuĂ±oz-Barrutia, T. Blu, M. Unser, "Least-Squares Image Resizing Using Finite Differences," IEEE Transactions on Image Processing, vol. 10, n. 9, September 2001.

Use: `out(x) = input(x/scale)`; `scale > 1` expansion; `a < 1` reduction.

Use `n=n2`:

• if `(n1==-1)` the standard method (interpolation and resampling) is applied.
• If `(n=n1=n2)`, the orthogonal projection is computed. The error is the minimum in the least-squares sense.
• If `((n1 > -1) && (n1<n2))`, the oblique projection is computed. The error is slightly greater than the case above.
Parameters:
`input` - input signal
`n` - degree of the interpolation spline. It can vary from 0 to 3.
`n1` - degree of the analysis spline. It can vary from -1 to 3.
`n2` - degree of the synthesis spline. It can vary from 0 to 3.
`scale` - zoom factor (`scale > 1` expansion; `scale < 1` reduction)
`coefOrSamples` - if working with coefficients coefOrSamples is true; if working with samples coefOrSamples is false
Returns:
out signal
• #### convertToSamples

```public static double[] convertToSamples(double[] coef,
double[] samples)```
Convert the spline coefficients to samples
Parameters:
`coef` - input coefficients values
`samples` - output samples
Returns:
• #### finDiffAS

`public static double[] finDiffAS(double[] c)`
Finite Difference. Anti-symmetric input boundary conditions. Symmetric output boundary conditions.
Parameters:
`c` - input signal
Returns:
output signal
• #### resampling

```public static double[] resampling(double[] input,
int nInput,
int nOut,
double scale,
int n1,
int nt)```
Geometric transform and resampling
Parameters:
`input` - input signal
`nInput` - length of the input signal
`nOut` - length of the resize signal
`scale` - expansion/reduction
`n1` - degree of the analysis spline
`nt` - (n+n1+1)
Returns:
re-sampled signal
• #### factorial

`public static int factorial(int n)`
Factorial
Parameters:
`n` -
Returns:
n factorial
• #### integAS

`public static double[] integAS(double[] c)`
Begin computation of the running sums. The input boundary conditions are anti-symmetric. The output boundary conditions are symmetric.
Parameters:
`c` - input coefficients
Returns:
sums
• #### integSA

```public static double integSA(double[] c,
double[] z)```
Begin computation of the running sums. The input boundary conditions are symmetric. The output boundary conditions are anti-symmetric.
Parameters:
`c` - coefficients
`z` - sums
Returns:
mean value on the period (2*length(c)-2)
• #### mean

`public static double mean(double[] A)`
Calculate mean value on the period (2*length(A)-2)
Parameters:
`A` -
Returns:
mean value on the period (2*length(A)-2)
• #### convertToInterpCoef

```public static double[] convertToInterpCoef(double[] input,
double[] poles,
double tolerance)```
Convert to interpolation coefficients
Parameters:
`input` -
`poles` -
`tolerance` -
Returns:
• #### initialAntiCausalCoefficient

```public static double initialAntiCausalCoefficient(double[] c,
double z)```
Get initial anti-causal coefficients
Parameters:
`c` - coefficients
`z` - pole
Returns:
value of the initial anti-causal coefficient
• #### initialCausalCoefficient

```public static double initialCausalCoefficient(double[] c,
double z,
double tolerance)```
Initialization of causal coefficients for mirror boundary conditions
Parameters:
`c` - coefficients
`z` - pole
`tolerance` - accuracy
Returns:
value of the initial causal coefficient for the given accuracy
• #### tableOfPoles

`public static double[] tableOfPoles(int splineDegree)`
Recover the poles from a lookup table
Parameters:
`splineDegree` - degree of the spline
Returns:
Pole values
• #### tableOfSamples

`public static double[] tableOfSamples(int splineDegree)`
Recover the B-spline samples values from a lookup table
Parameters:
`splineDegree` - degree of the spline
Returns:
Value of the samples