oa::image

image module in the OA Vision public surface.

MdRust public API

Public Types

Public Functions

pub fn adaptive_threshold_gaussian( input: &Image, kernel_size: u32, c: f32, max_value: f32, sigma: f32, border: BorderMode, ) -> Result<Image>
pub fn adaptive_threshold_mean( input: &Image, kernel_size: u32, c: f32, max_value: f32, border: BorderMode, ) -> Result<Image>
pub fn alpha_blend(a: &Image, b: &Image, alpha: f32) -> Result<Image>
pub fn average_blur( input: &Image, width: u32, height: u32, border: BorderMode, ) -> Result<Image>
pub fn bilateral_filter( input: &Image, kernel_size: u32, sigma_color: f32, sigma_space: f32, border: BorderMode, ) -> Result<Image>
pub fn brightness_contrast( input: &Image, brightness: f32, contrast: f32, ) -> Result<Image>
pub const fn can_decode(codec: ImageCodec) -> bool
pub const fn can_encode(codec: ImageCodec) -> bool
pub fn center_crop(input: &Image, width: u32, height: u32) -> Result<Image>
pub fn channel_reorder( input: &Image, order: [u32; 4], output_format: ImageFormat, ) -> Result<Image>
pub fn clamp(input: &Image, low: f32, high: f32) -> Result<Image>
pub fn color_twist(input: &Image, transform: &Matrix) -> Result<Image>
pub fn composite(a: &Image, b: &Image, mask: &Image) -> Result<Image>
pub fn convert_color( input: &Image, destination_format: ImageFormat, ) -> Result<Image>
pub fn convolve_2d( input: &Image, kernel: &Matrix, border: BorderMode, border_value: f32, ) -> Result<Image>
pub fn crop( input: &Image, x: u32, y: u32, width: u32, height: u32, ) -> Result<Image>
pub fn decode_file( engine: &Engine, path: impl AsRef<Path>, format: ImageFormat, ) -> Result<Image>
pub fn decode_memory( engine: &Engine, encoded: &[u8], format: ImageFormat, ) -> Result<Image>
pub fn dilate( input: &Image, width: u32, height: u32, border: BorderMode, border_value: f32, ) -> Result<Image>
pub fn encode(image: &Image, codec: ImageCodec, quality: u32) -> Result<Vec<u8>>
pub fn erase( input: &Image, x: u32, y: u32, width: u32, height: u32, value: f32, ) -> Result<Image>
pub fn erode( input: &Image, width: u32, height: u32, border: BorderMode, border_value: f32, ) -> Result<Image>
pub fn flip(input: &Image, horizontal: bool, vertical: bool) -> Result<Image>
pub fn gamma_contrast(input: &Image, gamma: f32, gain: f32) -> Result<Image>
pub fn gaussian_blur( input: &Image, sigma: f32, kernel_size: u32, ) -> Result<Image>
pub fn gaussian_noise( input: &Image, mean: f32, stddev: f32, seed: u64, ) -> Result<Image>
pub fn grayscale(input: &Image) -> Result<Image>
pub fn in_range( input: &Image, low: f32, high: f32, true_value: f32, ) -> Result<Image>
pub fn invert(input: &Image, max_value: f32) -> Result<Image>
pub fn laplacian(input: &Image, border: BorderMode) -> Result<Image>
pub fn median_blur( input: &Image, kernel_size: u32, border: BorderMode, ) -> Result<Image>
pub fn morphology_black_hat( input: &Image, width: u32, height: u32, border: BorderMode, border_value: f32, ) -> Result<Image>
pub fn morphology_close( input: &Image, width: u32, height: u32, border: BorderMode, border_value: f32, ) -> Result<Image>
pub fn morphology_gradient( input: &Image, width: u32, height: u32, border: BorderMode, border_value: f32, ) -> Result<Image>
pub fn morphology_open( input: &Image, width: u32, height: u32, border: BorderMode, border_value: f32, ) -> Result<Image>
pub fn morphology_top_hat( input: &Image, width: u32, height: u32, border: BorderMode, border_value: f32, ) -> Result<Image>
pub fn normalize( input: &Image, parameters: NormalizationParams, ) -> Result<Image>
pub fn pad( input: &Image, left: u32, right: u32, top: u32, bottom: u32, border: BorderMode, border_value: f32, ) -> Result<Image>
pub fn posterize( input: &Image, levels: u32, low: f32, high: f32, ) -> Result<Image>
pub fn remap( input: &Image, map: &Matrix, interpolation: InterpolationMode, border: BorderMode, border_value: f32, ) -> Result<Image>
pub fn resize( input: &Image, target_width: u32, target_height: u32, interpolation: InterpolationMode, ) -> Result<Image>
pub fn resize_normalize( input: &Image, width: u32, height: u32, parameters: NormalizationParams, ) -> Result<Image>
pub fn rotate(input: &Image, degrees: u32) -> Result<Image>
pub fn salt_pepper_noise( input: &Image, probability: f32, salt_value: f32, pepper_value: f32, seed: u64, ) -> Result<Image>
pub fn save_file( path: impl AsRef<Path>, image: &Image, quality: u32, ) -> Result<()>
pub fn save_rgba_file( rgba: &[u8], width: u32, height: u32, path: impl AsRef<Path>, quality: u32, ) -> Result<()>
pub fn scharr( input: &Image, dx: u32, dy: u32, border: BorderMode, ) -> Result<Image>
pub fn segmentation_overlay( input: &Image, mask: &Matrix, palette: &Matrix, alpha: f32, ) -> Result<Image>
pub fn separable_convolve_2d( input: &Image, kernel_x: &Matrix, kernel_y: &Matrix, border: BorderMode, border_value: f32, ) -> Result<Image>
pub fn sharpen(input: &Image, amount: f32, border: BorderMode) -> Result<Image>
pub fn sobel( input: &Image, dx: u32, dy: u32, border: BorderMode, ) -> Result<Image>
pub fn solarize(input: &Image, threshold: f32, max_value: f32) -> Result<Image>
pub fn threshold_binary( input: &Image, threshold: f32, max_value: f32, ) -> Result<Image>
pub fn threshold_binary_inv( input: &Image, threshold: f32, max_value: f32, ) -> Result<Image>
pub fn threshold_to_zero(input: &Image, threshold: f32) -> Result<Image>
pub fn threshold_to_zero_inv(input: &Image, threshold: f32) -> Result<Image>
pub fn threshold_truncate(input: &Image, threshold: f32) -> Result<Image>
pub fn unsharp_mask( input: &Image, sigma: f32, amount: f32, kernel_size: u32, ) -> Result<Image>
pub fn warp_affine( input: &Image, transform: &Matrix, width: u32, height: u32, interpolation: InterpolationMode, border: BorderMode, border_value: f32, ) -> Result<Image>
pub fn warp_perspective( input: &Image, transform: &Matrix, width: u32, height: u32, interpolation: InterpolationMode, border: BorderMode, border_value: f32, ) -> Result<Image>

Function Documentation

pub fn adaptive_threshold_gaussian( input: &Image, kernel_size: u32, c: f32, max_value: f32, sigma: f32, border: BorderMode ) -> Result<Image>
Threshold against a local Gaussian-weighted mean minus c.
pub fn adaptive_threshold_mean( input: &Image, kernel_size: u32, c: f32, max_value: f32, border: BorderMode ) -> Result<Image>
Threshold against the local arithmetic mean minus c.
pub fn alpha_blend( a: &Image, b: &Image, alpha: f32 ) -> Result<Image>
Blend two equal semantic images using a * (1-alpha) + b * alpha.
pub fn average_blur( input: &Image, width: u32, height: u32, border: BorderMode ) -> Result<Image>
Average an odd rectangular neighborhood up to 31×31.
pub fn bilateral_filter( input: &Image, kernel_size: u32, sigma_color: f32, sigma_space: f32, border: BorderMode ) -> Result<Image>
Apply a bilateral neighborhood filter.
pub fn brightness_contrast( input: &Image, brightness: f32, contrast: f32 ) -> Result<Image>
Apply value * contrast + brightness.
pub const fn can_decode( codec: ImageCodec ) -> bool
Return whether this build can decode codec.
pub const fn can_encode( codec: ImageCodec ) -> bool
Return whether this build can encode codec.
pub fn center_crop( input: &Image, width: u32, height: u32 ) -> Result<Image>
Extract a centered region with the requested exact extent.
pub fn channel_reorder( input: &Image, order: [u32; 4], output_format: ImageFormat ) -> Result<Image>
Reorder one to four channels and explicitly assign the resulting format. order[c] selects the source channel for output channel c. The output format must have the same channel count as the input so pixel data and semantic metadata cannot diverge.
pub fn clamp( input: &Image, low: f32, high: f32 ) -> Result<Image>
Clamp every pixel to the inclusive interval.
pub fn color_twist( input: &Image, transform: &Matrix ) -> Result<Image>
Apply one shared FP32 [3, 4] affine color transform to RGB channels.
pub fn composite( a: &Image, b: &Image, mask: &Image ) -> Result<Image>
Composite two equal images with a clamped Gray or per-channel mask.
pub fn convert_color( input: &Image, destination_format: ImageFormat ) -> Result<Image>
Convert between three-channel RGB and BGR semantics, including identity.
pub fn convolve_2d( input: &Image, kernel: &Matrix, border: BorderMode, border_value: f32 ) -> Result<Image>
Apply same-shape 2D cross-correlation with an odd FP32 kernel up to 31×31.
pub fn crop( input: &Image, x: u32, y: u32, width: u32, height: u32 ) -> Result<Image>
Extract a region, clipping its right and bottom edges to the source extent.
pub fn decode_file( engine: &Engine, path: impl AsRef<Path>, format: ImageFormat ) -> Result<Image>
Decode a JPEG, PNG, WebP, BMP, or TGA file and upload normalized planar FP32 pixels. The result is one NCHW image shaped [1, channels, height, width]. This is a synchronous host codec boundary followed by device upload. Errors Returns an error for an empty path, filesystem failure, unsupported or malformed media, unsupported requested format, checked-size overflow, or device allocation/upload failure.
pub fn decode_memory( engine: &Engine, encoded: &[u8], format: ImageFormat ) -> Result<Image>
Decode JPEG, PNG, WebP, BMP, or TGA bytes and upload normalized planar FP32 pixels. The requested output format may be Gray, Rgb, or Rgba. The result is one NCHW image shaped [1, channels, height, width]. Errors Returns an error for empty, unsupported, or malformed media, unsupported requested format, checked-size overflow, or device allocation/upload failure.
pub fn dilate( input: &Image, width: u32, height: u32, border: BorderMode, border_value: f32 ) -> Result<Image>
Dilate with an odd rectangular structuring element up to 31×31.
pub fn encode( image: &Image, codec: ImageCodec, quality: u32 ) -> Result<Vec<u8>>
Read normalized planar FP32 pixels and encode one still-image bitstream. quality is used by the lossy JPEG and WebP encoders and must be in [1, 100] for those codecs. This is an explicit blocking host-observation boundary. Errors Returns an error for Auto, unsupported image metadata, invalid quality, readback failure, checked-size overflow, or codec failure.
pub fn erase( input: &Image, x: u32, y: u32, width: u32, height: u32, value: f32 ) -> Result<Image>
Fill the intersection of a rectangle and the image with one finite value.
pub fn erode( input: &Image, width: u32, height: u32, border: BorderMode, border_value: f32 ) -> Result<Image>
Erode with an odd rectangular structuring element up to 31×31.
pub fn flip( input: &Image, horizontal: bool, vertical: bool ) -> Result<Image>
Flip an image horizontally, vertically, or along both axes.
pub fn gamma_contrast( input: &Image, gamma: f32, gain: f32 ) -> Result<Image>
Apply max(value, 0)^gamma * gain.
pub fn gaussian_blur( input: &Image, sigma: f32, kernel_size: u32 ) -> Result<Image>
Apply a normalized Gaussian blur with replicate borders.
pub fn gaussian_noise( input: &Image, mean: f32, stddev: f32, seed: u64 ) -> Result<Image>
Add explicit-seed Philox Gaussian noise to every pixel.
pub fn grayscale( input: &Image ) -> Result<Image>
Convert an RGB or RGBA image to Rec.709 grayscale.
pub fn in_range( input: &Image, low: f32, high: f32, true_value: f32 ) -> Result<Image>
Produce true_value for values inside the inclusive interval and zero outside it.
pub fn invert( input: &Image, max_value: f32 ) -> Result<Image>
Invert every value around max_value.
pub fn laplacian( input: &Image, border: BorderMode ) -> Result<Image>
Apply the four-neighbor discrete Laplacian.
pub fn median_blur( input: &Image, kernel_size: u32, border: BorderMode ) -> Result<Image>
Select the median of an odd square neighborhood up to 15×15.
pub fn morphology_black_hat( input: &Image, width: u32, height: u32, border: BorderMode, border_value: f32 ) -> Result<Image>
Return the morphological closing minus the source.
pub fn morphology_close( input: &Image, width: u32, height: u32, border: BorderMode, border_value: f32 ) -> Result<Image>
Dilate and then erode with the same rectangular element.
pub fn morphology_gradient( input: &Image, width: u32, height: u32, border: BorderMode, border_value: f32 ) -> Result<Image>
Return dilation minus erosion.
pub fn morphology_open( input: &Image, width: u32, height: u32, border: BorderMode, border_value: f32 ) -> Result<Image>
Erode and then dilate with the same rectangular element.
pub fn morphology_top_hat( input: &Image, width: u32, height: u32, border: BorderMode, border_value: f32 ) -> Result<Image>
Return the source minus its morphological opening.
pub fn normalize( input: &Image, parameters: NormalizationParams ) -> Result<Image>
Apply (pixel - mean[channel]) / std[channel] to up to three channels.
pub fn pad( input: &Image, left: u32, right: u32, top: u32, bottom: u32, border: BorderMode, border_value: f32 ) -> Result<Image>
Add asymmetric padding with an explicit border policy.
pub fn posterize( input: &Image, levels: u32, low: f32, high: f32 ) -> Result<Image>
Quantize [low, high] to levels evenly spaced values using round-half-up.
pub fn remap( input: &Image, map: &Matrix, interpolation: InterpolationMode, border: BorderMode, border_value: f32 ) -> Result<Image>
Resample an image from an FP32 absolute-coordinate map shaped [1|batch, 2, output_height, output_width].
pub fn resize( input: &Image, target_width: u32, target_height: u32, interpolation: InterpolationMode ) -> Result<Image>
Resize an FP32 channel-first image while preserving its layout and format. NCHW and CHW storage are supported. Nearest sampling follows the donor OA floor-coordinate rule. Bilinear sampling uses half-pixel centers with align_corners = false. The call records work asynchronously and returns an Image immediately. Reading its backing matrix is an explicit submission and observation point. Errors Returns an error for a zero target extent, an empty source extent, a dtype or layout outside the admitted checkpoint, checked-size overflow, or a runtime recording failure.
pub fn resize_normalize( input: &Image, width: u32, height: u32, parameters: NormalizationParams ) -> Result<Image>
Bilinearly resize and normalize in one semantic and executable operation.
pub fn rotate( input: &Image, degrees: u32 ) -> Result<Image>
Rotate clockwise by a multiple of 90 degrees.
pub fn salt_pepper_noise( input: &Image, probability: f32, salt_value: f32, pepper_value: f32, seed: u64 ) -> Result<Image>
Replace a seeded fraction of pixels with salt or pepper values.
pub fn save_file( path: impl AsRef<Path>, image: &Image, quality: u32, ) -> Result<()>
Encode an Image using the codec inferred from the output extension and save it. Supported extensions are .jpg, .jpeg, .png, .webp, .bmp, and .tga. This is an explicit blocking device-readback and filesystem boundary. Errors Returns an error for an empty or unsupported path, invalid image or quality, readback or encoding failure, or a host filesystem failure.
pub fn save_rgba_file( rgba: &[u8], width: u32, height: u32, path: impl AsRef<Path>, quality: u32, ) -> Result<()>
Encode and save one exact packed RGBA8 host image. This is the host sink used by render sessions after their own explicit completion and readback protocol has produced packed bytes. Errors Returns an error for an empty or unsupported path, zero or overflowing dimensions, a mismatched byte count, invalid quality, codec failure, or a host filesystem failure.
pub fn scharr( input: &Image, dx: u32, dy: u32, border: BorderMode ) -> Result<Image>
Compute one first-order Scharr derivative.
pub fn segmentation_overlay( input: &Image, mask: &Matrix, palette: &Matrix, alpha: f32 ) -> Result<Image>
Blend a class palette over an RGB/RGBA image using an I32 label map.
pub fn separable_convolve_2d( input: &Image, kernel_x: &Matrix, kernel_y: &Matrix, border: BorderMode, border_value: f32 ) -> Result<Image>
Apply horizontal and vertical odd FP32 vector kernels up to length 31.
pub fn sharpen( input: &Image, amount: f32, border: BorderMode ) -> Result<Image>
Apply a nonnegative four-neighbor sharpening amount.
pub fn sobel( input: &Image, dx: u32, dy: u32, border: BorderMode ) -> Result<Image>
Compute one first-order Sobel derivative.
pub fn solarize( input: &Image, threshold: f32, max_value: f32 ) -> Result<Image>
Invert values at or above threshold around max_value.
pub fn threshold_binary( input: &Image, threshold: f32, max_value: f32 ) -> Result<Image>
Replace values above threshold with max_value and all others with zero.
pub fn threshold_binary_inv( input: &Image, threshold: f32, max_value: f32 ) -> Result<Image>
Replace values at or below threshold with max_value and all others with zero.
pub fn threshold_to_zero( input: &Image, threshold: f32 ) -> Result<Image>
Replace values at or below threshold with zero.
pub fn threshold_to_zero_inv( input: &Image, threshold: f32 ) -> Result<Image>
Replace values above threshold with zero.
pub fn threshold_truncate( input: &Image, threshold: f32 ) -> Result<Image>
Truncate values above threshold.
pub fn unsharp_mask( input: &Image, sigma: f32, amount: f32, kernel_size: u32 ) -> Result<Image>
Apply an unsharp mask using a Gaussian detail estimate.
pub fn warp_affine( input: &Image, transform: &Matrix, width: u32, height: u32, interpolation: InterpolationMode, border: BorderMode, border_value: f32 ) -> Result<Image>
Apply an inverse FP32 2x3 affine transform to an image.
pub fn warp_perspective( input: &Image, transform: &Matrix, width: u32, height: u32, interpolation: InterpolationMode, border: BorderMode, border_value: f32 ) -> Result<Image>
Apply an inverse FP32 3x3 perspective transform to an image.