Skip to main content

Mojo function

cubic_kernel

cubic_kernel(x: Float32) -> Float32

Cubic interpolation kernel matching PyTorch/torchvision's BICUBIC filter.

This uses the Catmull-Rom variant (Robidoux cubic) with a = -0.75, which is what PyTorch uses in get_cubic_upsample_coefficients. (Source). This also matches OpenCV's interpolateCubic.

Args:

  • x (Float32): Distance from the center point.

Returns:

Float32: Weight contribution based on the distance.

cubic_kernel(x: SIMD[dtype, size]) -> SIMD[dtype, size]

Cubic interpolation kernel matching PyTorch/torchvision's BICUBIC filter.

This uses the Catmull-Rom variant (Robidoux cubic) with a = -0.75, which is what PyTorch uses in get_cubic_upsample_coefficients. (Source). This also matches OpenCV's interpolateCubic.

Args:

  • x (SIMD): Distance from the center point.

Returns:

SIMD: Weight contribution based on the distance.

Was this page helpful?