sporco.interp¶
Interpolation and regression functions.
Functions
|
Demosaicing by bilinear interpolation. |
|
|
|
Least absolute deviations (LAD) linear regression. |
|
Least maximum deviation (least maximum error) linear regression. |
|
Lanczos interpolation kernel. |
|
Evenly spaced interpolation points. |
|
Multi-dimensional Lanczos interpolation filters. |
Function Descriptions¶
- sporco.interp.bilinear_demosaic(img)[source]¶
Demosaicing by bilinear interpolation.
The input is assumed to be an image formed with a colour filter array with the pattern
B G B G ... G R G R ... B G B G ... G R G R ... . . . . . . . . . . . . . . .
- Parameters
- img2d ndarray
A 2d array representing an image formed with a colour filter array
- Returns
- imgd3d ndarray
Demosaiced 3d image
- sporco.interp.lstabsdev(A, b)[source]¶
Least absolute deviations (LAD) linear regression.
Solve the linear regression problem
\[\mathrm{argmin}_\mathbf{x} \; \left\| A \mathbf{x} - \mathbf{b} \right\|_1 \;\;.\]The interface is similar to that of
numpy.linalg.lstsq
in that np.linalg.lstsq(A, b) solves the same linear regression problem, but with a least squares rather than a least absolute deviations objective. Unlikenumpy.linalg.lstsq
, b is required to be a 1-d array. The solution is obtained via mapping to a linear program. The current implementation is only suitable for small-scale problems.
- Parameters
- A(M, N) array_like
Regression coefficient matrix
- b(M,) array_like
Regression ordinate / dependent variable
- Returns
- x(N,) ndarray
Least absolute deviations solution
- sporco.interp.lstmaxdev(A, b)[source]¶
Least maximum deviation (least maximum error) linear regression.
Solve the linear regression problem
\[\mathrm{argmin}_\mathbf{x} \; \left\| A \mathbf{x} - \mathbf{b} \right\|_{\infty} \;\;.\]The interface is similar to that of
numpy.linalg.lstsq
in that np.linalg.lstsq(A, b) solves the same linear regression problem, but with a least squares rather than a least maximum error objective. Unlikenumpy.linalg.lstsq
, b is required to be a 1-d array. The solution is obtained via mapping to a linear program. The current implementation is only suitable for small-scale problems.
- Parameters
- A(M, N) array_like
Regression coefficient matrix
- b(M,) array_like
Regression ordinate / dependent variable
- Returns
- x(N,) ndarray
Least maximum deviation solution
- sporco.interp.lanczos_kernel(x, a=3)[source]¶
Lanczos interpolation kernel.
Compute the Lanczos interpolation kernel
\[\begin{split}L(x) = \left\{ \begin{array}{ll} \mathrm{sinc}(x)\, \mathrm{sinc}(x/a) & \;\text{if}\; -a < x < a \\ 0 & \text{otherwise} \;, \end{array} \right.\end{split}\]where \(a \in \mathbb{Z}^+\).
- Parameters
- xfloat or ndarray
Sampling point(s) at which to compute the kernel
- aint, optional (default 3)
Kernel size parameter
- Returns
- yfloat or ndarray
Kernel evaluated at sampling point(s)
- sporco.interp.interpolation_points(N, include_zero=True)[source]¶
Evenly spaced interpolation points.
Construct a set of N evenly spaced interpolation points for samples on an integer grid.
- Parameters
- Nint
Number of interpolation points
- include_zerobool, optional (default True)
Flag indicating whether to include zero in the set of points
- Returns
- yndarray
Array of interpolation points
- sporco.interp.lanczos_filters(sz, a=3, collapse_axes=True)[source]¶
Multi-dimensional Lanczos interpolation filters.
Construct a set of Lanczos interpolation filters. Multi-dimensional filters are constructed as tensor products of one-dimensional filters.
- Parameters
- sztuple of int or tuple of array_like
Tuple specifying the resampling points for each filter dimension. Each entry may be an array of resampling points or an integer, in which case the resampling grid consists of the specified number of equi-spaced points
- aint, optional (default 3)
Kernel size parameter
- collapse_axesbool, optional (default True)
Flag indicating whether to collapse the output axes corresponding to different filters for each filter dimension
- Returns
- yndarray
Array of interpolation filters