imwip.functions
imwip.functions.functions_dvf
- file
functions_dvf.py
- brief
Image warping functions using a DVF
- author
Jens Renders
- imwip.functions.functions_dvf.warp(image, u, v, w=None, out=None, degree=3, backend=None)
Warps a 2D or 3D image along a DVF.
This function is linear in terms of the input image (even if degree 3 is used for the splines). Therefore it has an adjoint function which is computed by
adjoint_warp().- Parameters
image (
numpy.ndarray) – Input imageu (
numpy.ndarray) – First component of the DVF describing the warpv (
numpy.ndarray) – Second component of the DVF describing the warpw (
numpy.ndarray, optional) – Third component of the DVF describing the warp. Leave empty for a 2D warpout (
numpy.ndarray, optional) – Array to write the output image in. If None, an output array will be allocated.degree (1 or 3, optional) – Degree of the splines used for interpolation
backend (
cppornumba, optional) – Whether to use the cpp or numba backend. If None,cppwill be used if available, elsenumba
- Returns
The warped image
- Return type
- imwip.functions.functions_dvf.adjoint_warp(image, u, v, w=None, out=None, degree=3, backend=None)
The function
warp()is a linear function of the input image (even if degree 3 is used for the splines). Therefore it has an adjoint function which is computed by this function, as described by Renders et al. [RSDB21]. Seewarp()for the description of parameters and return value.
- imwip.functions.functions_dvf.diff_warp(image, u, v, w=None, diff_x=None, diff_y=None, diff_z=None, backend=None)
The derivative of
warp()towards the DVF. This function assumes splines of degree 3, to ensure differentiability.- Parameters
image (
numpy.ndarray) – Input imageu (
numpy.ndarray) – First component of the DVF describing the warpv (
numpy.ndarray) – Second component of the DVF describing the warpw (
numpy.ndarray, optional) – Third component of the DVF describing the warp. Leave empty for a 2D warpdiff_x (
numpy.ndarray, optional) – Array to write the derivative to the first component in. If None, an output array will be allocated.diff_y (
numpy.ndarray, optional) – Array to write the derivative to the first component in. If None, an output array will be allocated.diff_z (
numpy.ndarray, optional) – Array to write the derivative to the first component in. If None, an output array will be allocated.backend (
cppornumba, optional) – Whether to use the cpp or numba backend. If None,cppwill be used if available, elsenumba
- Returns
diff_x, diff_y, diff_z
- Return type
imwip.functions.functions_affine
- file
functions_affine.py
- brief
Image warping functions using an affine transformation
- author
Jens Renders
- imwip.functions.functions_affine.affine_warp(image, A, b, out=None, degree=3, indexing='ij', backend=None)
Warps a 2D or 3D image according to an affine transformation Ax + b.
This function is linear in terms of the input image (even if degree 3 is used for the splines). Therefore it has an adjoint function which is computed by
adjoint_affine_warp().- Parameters
image (
numpy.ndarray) – Input imageA (
numpy.ndarray) – Matrix A of the affine transformation Ax + b. It shoud be an 2x2 for 2D warp and 3x3 for a 3D warp.b (
numpy.ndarray) – Vector b of the affine transformation Ax + b. It should have length 2 for a 2D warp and length 3 for a 3D warp.out (
numpy.ndarray, optional) – Array to write the output image in. If None, an output array will be allocated.degree (1 or 3, optional) – Degree of the splines used for interpolation
indexing (
ijorxy, optional) –ijuses standard numpy array indexing. “xy” reversed the order of the indexes, making the vertical axis the first index. This can be more intuitive for 2D arrays. Defaults toij.backend (
cppornumba, optional) – Whether to use the cpp or numba backend. If None,cppwill be used if available, elsenumba
- Returns
The warped image
- Return type
- imwip.functions.functions_affine.adjoint_affine_warp(image, A, b, out=None, degree=3, indexing='ij', backend=None)
The function
affine_warp()is a linear function of the input image (even if degree 3 is used for the splines). Therefore it has an adjoint function which is computed by this function, as described by Renders et al. [RSDB21]. Seeaffine_warp()for the description of parameters and return value.
- imwip.functions.functions_affine.diff_affine_warp(image, A, b, diff_x=None, diff_y=None, diff_z=None, indexing='ij', backend=None)
The derivative of
affine_warp()towards the DVF describing the affine warp. This function assumes splines of degree 3, to ensure differentiability.- Parameters
image (
numpy.ndarray) – Input imageA (
numpy.ndarray) – Matrix A of the affine transformation Ax + b. It shoud be an 2x2 for 2D warp and 3x3 for a 3D warp.b (
numpy.ndarray) – Vector b of the affine transformation Ax + b. It should have length 2 for a 2D warp and length 3 for a 3D warp.diff_x – Array to write the derivative to the first component in. If None, an output array will be allocated.
diff_y – Array to write the derivative to the first component in. If None, an output array will be allocated.
diff_z – Array to write the derivative to the first component in. If None, an output array will be allocated.
indexing (
ijorxy, optional) –ijuses standard numpy array indexing. “xy” reversed the order of the indexes, making the vertical axis the first index. This can be more intuitive for 2D arrays. Defaults toij.backend (
cppornumba, optional) – Whether to use the cpp or numba backend. If None,cppwill be used if available, elsenumba
- Returns
diff_x, diff_y, diff_z
- Return type