IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Interpolation.h
Go to the documentation of this file.
1 // Interpolation.h:
3 // ----------------
4 //
14 
15 #ifndef __IPSDKMATH_INTERPOLATION_H__
16 #define __IPSDKMATH_INTERPOLATION_H__
17 
19 #include <IPSDKUtil/BaseTypes.h>
21 
22 namespace ipsdk {
23 namespace math {
24 
27 
33 IPSDK_FORCEINLINE ipReal64
34 linearInterpolation(const ipReal64 x, const ipReal64 f0, const ipReal64 f1)
35 {
36  return (1-x)*f0 + x*f1;
37 }
38 
47 IPSDK_FORCEINLINE ipReal64
49  const ipReal64 fX0Y0, const ipReal64 fX1Y0,
50  const ipReal64 fX0Y1, const ipReal64 fX1Y1)
51 {
52  const ipReal64 fY0 = linearInterpolation(x, fX0Y0, fX1Y0);
53  const ipReal64 fY1 = linearInterpolation(x, fX0Y1, fX1Y1);
54  return linearInterpolation(y, fY0, fY1);
55 }
56 
70 IPSDK_FORCEINLINE ipReal64
72  const ipReal64 fX0Y0Z0, const ipReal64 fX1Y0Z0,
73  const ipReal64 fX0Y1Z0, const ipReal64 fX1Y1Z0,
74  const ipReal64 fX0Y0Z1, const ipReal64 fX1Y0Z1,
75  const ipReal64 fX0Y1Z1, const ipReal64 fX1Y1Z1)
76 {
77  const ipReal64 fZ0 = biLinearInterpolation(x, y, fX0Y0Z0, fX1Y0Z0, fX0Y1Z0, fX1Y1Z0);
78  const ipReal64 fZ1 = biLinearInterpolation(x, y, fX0Y0Z1, fX1Y0Z1, fX0Y1Z1, fX1Y1Z1);
79  return linearInterpolation(z, fZ0, fZ1);
80 }
81 
91 IPSDK_FORCEINLINE ipReal64
93  const ipReal64 fM1, const ipReal64 f0,
94  const ipReal64 f1, const ipReal64 f2)
95 {
96  return f0 + 0.5 * x*(f1 - fM1 + x*(2.0*fM1 - 5.0*f0 + 4.0*f1 - f2 + x*(3.0*(f0 - f1) + f2 - fM1)));
97 }
98 
109 IPSDK_FORCEINLINE ipReal64
111  const ipReal64 f[4][4])
112 {
113  const ipReal64 fYM1 = cubicInterpolation(x, f[0][0], f[0][1], f[0][2], f[0][3]);
114  const ipReal64 fY0 = cubicInterpolation(x, f[1][0], f[1][1], f[1][2], f[1][3]);
115  const ipReal64 fY1 = cubicInterpolation(x, f[2][0], f[2][1], f[2][2], f[2][3]);
116  const ipReal64 fY2 = cubicInterpolation(x, f[3][0], f[3][1], f[3][2], f[3][3]);
117  return cubicInterpolation(y, fYM1, fY0, fY1, fY2);
118 }
119 
131 IPSDK_FORCEINLINE ipReal64
133  const ipReal64 f[4][4][4])
134 {
135  const ipReal64 fZM1 = biCubicInterpolation(x, y, f[0]);
136  const ipReal64 fZ0 = biCubicInterpolation(x, y, f[1]);
137  const ipReal64 fZ1 = biCubicInterpolation(x, y, f[2]);
138  const ipReal64 fZ2 = biCubicInterpolation(x, y, f[3]);
139  return cubicInterpolation(z, fZM1, fZ0, fZ1, fZ2);
140 }
141 
144 
145 } // end of namespace math
146 } // end of namespace ipsdk
147 
148 #endif // __IPSDKMATH_INTERPOLATION_H__
Definition of import/export macro for library.
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
IPSDK_FORCEINLINE ipReal64 linearInterpolation(const ipReal64 x, const ipReal64 f0, const ipReal64 f1)
function allowing to compute linear interpolation between two values
Definition: Interpolation.h:34
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
IPSDK_FORCEINLINE ipReal64 triLinearInterpolation(const ipReal64 x, const ipReal64 y, const ipReal64 z, const ipReal64 fX0Y0Z0, const ipReal64 fX1Y0Z0, const ipReal64 fX0Y1Z0, const ipReal64 fX1Y1Z0, const ipReal64 fX0Y0Z1, const ipReal64 fX1Y0Z1, const ipReal64 fX0Y1Z1, const ipReal64 fX1Y1Z1)
function allowing to compute a tri linear interpolation
Definition: Interpolation.h:71
Base types for multiplatform compatibility.
IPSDK_FORCEINLINE ipReal64 cubicInterpolation(const ipReal64 x, const ipReal64 fM1, const ipReal64 f0, const ipReal64 f1, const ipReal64 f2)
function allowing to compute cubic interpolation between two values
Definition: Interpolation.h:92
IPSDK_FORCEINLINE ipReal64 biCubicInterpolation(const ipReal64 x, const ipReal64 y, const ipReal64 f[4][4])
function allowing to compute a bi cubic interpolation
Definition: Interpolation.h:110
IPSDK_FORCEINLINE ipReal64 triCubicInterpolation(const ipReal64 x, const ipReal64 y, const ipReal64 z, const ipReal64 f[4][4][4])
function allowing to compute a tri cubic interpolation
Definition: Interpolation.h:132
IPSDK_FORCEINLINE ipReal64 biLinearInterpolation(const ipReal64 x, const ipReal64 y, const ipReal64 fX0Y0, const ipReal64 fX1Y0, const ipReal64 fX0Y1, const ipReal64 fX1Y1)
function allowing to compute a bi linear interpolation
Definition: Interpolation.h:48