Mojo module
bicubic
This module provides CPU and GPU implementations for bicubic interpolation.
Bicubic interpolation is a 2D extension of cubic interpolation for resampling digital images. It uses the weighted average of the 4x4 neighborhood of pixels around the target location to compute the interpolated value.
Functions
-
cpu_bicubic_kernel
: Perform bicubic interpolation on an NDBuffer of form NCHW. -
cubic_kernel
: Cubic interpolation kernel matching PyTorch/torchvision's BICUBIC filter. -
gpu_bicubic_kernel
: Perform bicubic interpolation using GPU. -
map_output_to_input_coord
: Map output pixel coordinate to input coordinate using center alignment. This implements the standard coordinate mapping for image resizing: input_coord = (output_coord + 0.5) * scale - 0.5 The +0.5 and -0.5 terms ensure pixel centers are aligned properly. Args: output_coord: Output pixel coordinate. scale: Scale factor (input_size / output_size). Returns: Corresponding input coordinate as a float. -
resize_bicubic
: Perform bicubic interpolation.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!