pivuq.warping
- pivuq.warping.interpolate_to_pixel(U, imshape, kind='linear') ndarray [source]
Interpolate velocity field to pixel level.
- Parameters:
U (
np.ndarray
) – Sparse 2D velocity field.imshape (
tuple
) – Image frame dimension (rows, cols).kind (
{"linear", "cubic", "quintic"}
, default:"linear"
) – The kind of spline interpolation for scipy.interpolation.interp2d.
- Returns:
Pixel-wise 2D velocity field.
- Return type:
np.ndarray
- pivuq.warping.warp(image_pair, U, velocity_upsample_kind='linear', direction='center', nsteps=1, order=-1, radius=2) ndarray [source]
Warp image pair pixel-wise to each other using skimage.transform.warp.
- Parameters:
image_pair (
np.ndarray
) – Image pairs \(\mathbf{I} = (I_0, I_1)^{\top}\) of size \(2 \times N \times M\).U (
np.ndarray
) – Sparse or dense 2D velocity field \(\mathbf{U} = (u, v)^{\top}\) of size \(2 \times U_N \times U_M\).warp_direction (
{"forward", "center", "backward"}
, default:"center"
) – Warping warp_direction.velocity_upsample_kind (
{"linear", "cubic", "quintic"}
, default:"linear"
) – Velocity upsampling kind for spline interpolation scipy.interpolation.interp2d.nsteps (
int
, default:1
) – Number of sub-steps to use for warping to improve accuracy. Although, the original flow estimator (e.g. PIV) most likely uses \(n_{\mathrm{steps}}=1\).order (
-1
,1
,2 (bug)
,3
, default:-1
) – The order of interpolation for skimage.transform.warp. If order is negative, using Whittaker-Shannon interpolation.radius (
int
, default:3
) – Radius of the Whittaker-Shannon interpolation stencil.
- Returns:
Warped image pair \(\hat{\mathbf{I}} = (\hat{I}_0, \hat{I}_1)^{\top}\) of size \(2 \times N \times M\).
- Return type:
np.ndarray
- pivuq.warping.warp_skimage(frame, U, coords, order=1, mode='edge') ndarray [source]
Warp image frame pixel-wise using skimage.transform.warp.
- Parameters:
frame (
np.ndarray
) – image frame.U (
np.ndarray
) – pixel-wise 2D velocity field.coords (
np.ndarray
) – 2D image coordinates (row, cols).order (
1-5
, default:1
) – The order of interpolation for skimage.transform.warp.mode (
{"constant", "edge", "symmetric", "reflect", "wrap"}
, default:"edge"
) – Points outside the boundaries of the input are filled according to the given mode.
- Returns:
Warped image frame
- Return type:
np.ndarray
See also
skimage.transform.warp
Warp an image according to a given coordinate transformation.
- pivuq.warping.warp_whittaker(frame, U, coords, radius=3) ndarray [source]
Warp image using Whittaker-Shannon interpolation
- Parameters:
frame (
np.ndarray
) – image frame.U (
np.ndarray
) – pixel-wise 2D velocity field.coords (
np.ndarray
) – 2D image coordinates (row, cols).radius (
int
, default:3
) – Radius of the interpolation stencil.
- Returns:
Warped image frame
- Return type:
np.ndarray
See also
whittaker_interpolation
Whittaker-Shannon interpolation.
- pivuq.warping.whittaker_interpolation(im, xi, yi, r=3)[source]
Whittaker-Shannon interpolation [1].
- Parameters:
im (
np.ndarray
) – Image frame of shape (rows, cols).xi (
np.ndarray
) – The x and y-coordinates at which to evaluate the interpolated values of shape (rows, cols).yi (
np.ndarray
) – The x and y-coordinates at which to evaluate the interpolated values of shape (rows, cols).r (
int
, default:3
) – Radius of the interpolation stencil.
- Returns:
Interpolated image frame.
- Return type:
np.ndarray
References