Realm

oa::image

image module in the OA Vision public surface.

MdRust public API

Public Types

Public Functions

pub fn accumulate(input: &Image, accumulator: &Image) -> Result<Image>
pub fn accumulate_weighted( input: &Image, accumulator: &Image, alpha: f32, ) -> Result<Image>
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(left: &Image, right: &Image, alpha: f32) -> Result<Image>
pub fn apply_color_map(input: &Image, colormap: ColorMap) -> Result<Image>
pub fn average_blur( input: &Image, width: u32, height: u32, border: BorderMode, ) -> Result<Image>
pub fn bf_match(query: &Matrix, train: &Matrix) -> Result<Matrix>
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 fn calc_back_project( input: &Image, histogram: &Matrix, lower: f32, upper: f32, ) -> Result<Image>
pub fn calc_hist( input: &Image, bins: u32, lower: f32, upper: f32, ) -> Result<Matrix>
pub const fn can_decode(codec: ImageCodec) -> bool
pub const fn can_encode(codec: ImageCodec) -> bool
pub fn canny( input: &Image, low_threshold: f32, high_threshold: f32, hysteresis_passes: u32, ) -> Result<Image>
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 clahe( input: &Image, clip_limit: f32, tile_width: u32, tile_height: u32, ) -> 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 compare_hist( first: &Matrix, second: &Matrix, method: HistogramComparison, ) -> Result<Matrix>
pub fn composite(left: &Image, right: &Image, mask: &Image) -> Result<Image>
pub fn connected_components( input: &Image, threshold: f32, connectivity: Connectivity, propagation_passes: u32, ) -> Result<Matrix>
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 corner_fast(input: &Image, arc_length: u32) -> Result<Image>
pub fn corner_score( input: &Image, block_size: u32, k: f32, score_type: CornerScore, ) -> Result<Image>
pub fn crop( input: &Image, x: u32, y: u32, width: u32, height: u32, ) -> Result<Image>
pub fn cvt_color(input: &Image, conversion: ColorConversion) -> Result<Image>
pub fn decode_file(path: impl AsRef<Path>, format: ImageFormat) -> Result<Image>
pub fn decode_file_on( runtime: &Runtime, path: impl AsRef<Path>, format: ImageFormat, ) -> Result<Image>
pub fn decode_memory(encoded: &[u8], format: ImageFormat) -> Result<Image>
pub fn decode_memory_on( runtime: &Runtime, encoded: &[u8], format: ImageFormat, ) -> Result<Image>
pub fn dilate( input: &Image, width: u32, height: u32, border: BorderMode, border_value: f32, ) -> Result<Image>
pub fn distance_transform( input: &Image, threshold: f32, distance: DistanceType, propagation_passes: u32, ) -> Result<Matrix>
pub fn draw_circle( input: &Image, cx: f32, cy: f32, radius: f32, color: f32, thickness: f32, ) -> Result<Image>
pub fn draw_line( input: &Image, x1: f32, y1: f32, x2: f32, y2: f32, color: f32, thickness: f32, ) -> Result<Image>
pub fn draw_rectangle( input: &Image, x: f32, y: f32, width: f32, height: f32, color: f32, thickness: f32, ) -> Result<Image>
pub fn encode(image: &Image, codec: ImageCodec, quality: u32) -> Result<Vec<u8>>
pub fn equalize_hist(input: &Image) -> Result<Image>
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 estimate_affine_2d( source: &Matrix, destination: &Matrix, ) -> Result<Matrix>
pub fn fast_nl_means_denoising( input: &Image, h: f32, template_window: u32, search_window: u32, ) -> Result<Image>
pub fn fill_polygon(input: &Image, points: &Matrix, color: f32) -> Result<Image>
pub fn find_contours( input: &Image, threshold: f32, connectivity: Connectivity, max_contours: u32, max_points: u32, propagation_passes: u32, ) -> Result<(Matrix, Matrix)>
pub fn flip(input: &Image, horizontal: bool, vertical: bool) -> Result<Image>
pub fn flood_fill( input: &Image, seed_x: u32, seed_y: u32, value: f32, lo_diff: f32, up_diff: f32, connectivity: Connectivity, propagation_passes: u32, ) -> 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 good_features_to_track( input: &Image, max_corners: u32, quality: f32, min_distance: f32, ) -> Result<(Matrix, Matrix)>
pub fn grayscale(input: &Image) -> Result<Image>
pub fn hough_lines( input: &Image, edge_threshold: f32, rho_step: f32, theta_step: f32, threshold: u32, max_lines: u32, ) -> Result<Matrix>
pub fn hough_lines_p( input: &Image, edge_threshold: f32, rho_step: f32, theta_step: f32, threshold: u32, max_lines: u32, min_line_length: f32, max_line_gap: u32, ) -> Result<Matrix>
pub fn in_range( input: &Image, low: f32, high: f32, true_value: f32, ) -> Result<Image>
pub fn integral(input: &Image) -> Result<Matrix>
pub fn invert(input: &Image, max_value: f32) -> Result<Image>
pub fn invert_affine(matrix: &Matrix) -> Result<Matrix>
pub fn laplacian(input: &Image, border: BorderMode) -> Result<Image>
pub fn match_template( input: &Image, template: &Image, method: MatchTemplate, ) -> Result<Matrix>
pub fn median_blur( input: &Image, kernel_size: u32, border: BorderMode, ) -> Result<Image>
pub fn moments(input: &Image) -> Result<Matrix>
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 noise_like( input: &Image, distribution: NoiseDistribution, amplitude: f32, seed: u64, ) -> Result<Image>
pub fn normalize( input: &Image, parameters: NormalizationConfig, ) -> Result<Image>
pub fn optical_flow_farneback( previous: &Image, next: &Image, levels: u32, window: u32, iterations: u32, poly_n: u32, poly_sigma: f32, ) -> Result<Matrix>
pub fn optical_flow_pyr_lk( previous: &Image, next: &Image, points: &Matrix, levels: u32, window: u32, iterations: u32, min_eigen: f32, ) -> Result<(Matrix, Matrix, Matrix)>
pub fn orb( input: &Image, max_features: u32, quality: f32, min_distance: f32, levels: u32, edge: u32, ) -> Result<(Matrix, Matrix, Matrix)>
pub fn pad( input: &Image, left: u32, right: u32, top: u32, bottom: u32, border: BorderMode, border_value: f32, ) -> Result<Image>
pub fn perspective_transform( source: &Matrix, destination: &Matrix, ) -> Result<Matrix>
pub fn posterize( input: &Image, levels: u32, low: f32, high: f32, ) -> Result<Image>
pub fn psnr(first: &Image, second: &Image, peak_value: f32) -> Result<Matrix>
pub fn pyr_down(input: &Image) -> Result<Image>
pub fn pyr_mean_shift_filtering( input: &Image, sp: f32, sr: f32, max_level: u32, ) -> Result<Image>
pub fn pyr_up(input: &Image) -> Result<Image>
pub fn random_crop( input: &Image, width: u32, height: u32, seed: u64, ) -> Result<Image>
pub fn random_flip( input: &Image, p_horizontal: f32, p_vertical: f32, seed: u64, ) -> Result<Image>
pub fn random_rotate(input: &Image, seed: u64) -> Result<Image>
pub fn remap( input: &Image, map: &Matrix, interpolation: InterpolationMode, border: BorderMode, border_value: f32, ) -> Result<Image>
pub fn reproject_image_to_3d(disparity: &Matrix, q: &Matrix) -> Result<Matrix>
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: NormalizationConfig, ) -> Result<Image>
pub fn rotate(input: &Image, degrees: u32) -> Result<Image>
pub fn rotation_matrix_2d( center_x: f32, center_y: f32, angle: f32, scale: f32, ) -> Result<Matrix>
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 ssim(first: &Image, second: &Image) -> Result<Matrix>
pub fn stereo_bm( left: &Image, right: &Image, num_disparities: u32, block_size: u32, uniqueness: u32, ) -> Result<Matrix>
pub fn threshold_auto( input: &Image, method: AutoThreshold, max_value: f32, ) -> Result<(Image, Matrix)>
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>
pub fn warp_polar( input: &Image, center_x: f32, center_y: f32, max_radius: f32, out_width: u32, out_height: u32, mode: PolarMode, interpolation: InterpolationMode, border: BorderMode, border_value: f32, ) -> Result<Image>

Function Documentation

pub fn accumulate( input: &Image, accumulator: &Image ) -> Result<Image>
Add one image to a running accumulation image elementwise, following accumulate. Both images must share shape, layout, and format; the result is a fresh F32 image, not an in-place update. Errors Returns an error unless both images are nonempty FP32 NCHW/CHW images with identical shape, layout, and format.
pub fn accumulate_weighted( input: &Image, accumulator: &Image, alpha: f32 ) -> Result<Image>
Blend an image into a running average as input * alpha + accumulator * (1 - alpha) per element, following accumulateWeighted. Errors Returns an error unless both images are nonempty FP32 NCHW/CHW images with identical shape, layout, and format and alpha is finite.
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( left: &Image, right: &Image, alpha: f32 ) -> Result<Image>
Blend two equal semantic images using left * (1-alpha) + right * alpha.
pub fn apply_color_map( input: &Image, colormap: ColorMap ) -> Result<Image>
Map a single-channel FP32 image to RGB through a colormap. Each luminance value is clamped to [0, 1] and mapped by the admitted analytic colormap definition (Jet, Hot, Hsv, or Rainbow) to an RGB triplet, producing a three-channel Rgb image per plane following the applyColorMap contract. Errors Returns an error unless the image is nonempty FP32 NCHW/CHW with a single channel.
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 bf_match( query: &Matrix, train: &Matrix ) -> Result<Matrix>
Brute-force Hamming descriptor matching: for each row of query, scan every row of train and record the two smallest XOR popcount distances. Both inputs are U8 [N, D] matrices sharing D. Returns an F32 [N_query, 4] matrix whose rows are (best_index, best_distance, second_index, second_distance), mirroring BFMatcher.knnMatch(k=2) on NORM_HAMMING. Rows with fewer than two candidates fill unused columns with -1. Errors Returns an error unless both inputs are nonempty U8 matrices with identical trailing descriptor width and at least one row each.
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 fn calc_back_project( input: &Image, histogram: &Matrix, lower: f32, upper: f32 ) -> Result<Image>
Back-project a per-plane U32 histogram onto an FP32 image. Each pixel is quantized with the calc_hist rule over [lower, upper) into bins buckets taken from the histogram’s last dimension; the output pixel carries the histogram count as an FP32 value, or 0.0 when the source falls outside the range. Histogram leading dimensions must equal the image’s leading plane dimensions, following calcBackProject. Errors Returns an error unless the image is nonempty FP32 NCHW/CHW, the histogram is a nonempty U32 Matrix of matching leading shape, lower/upper are finite with lower < upper, and all sizes fit the shader ABI.
pub fn calc_hist( input: &Image, bins: u32, lower: f32, upper: f32 ) -> Result<Matrix>
Accumulate a per-plane histogram over an FP32 NCHW or CHW image. Each (batch, channel) plane contributes one row of bins buckets to the U32 result whose leading dimensions mirror the image; [B,C,H,W] and [C,H,W] inputs produce [B,C,bins] and [C,bins] results. Values below lower or at or above upper are ignored; in-range values map uniformly onto [0, bins). The accumulator is cleared inside the operation, so a captured plan replays the same counts. Errors Returns an error unless bins is in 1..=256, lower and upper are finite with lower < upper, the image is nonempty FP32 NCHW/CHW, and all sizes fit the shader ABI.
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 canny( input: &Image, low_threshold: f32, high_threshold: f32, hysteresis_passes: u32 ) -> Result<Image>
Canny edge detection per plane: 3x3 Sobel gradient magnitude, non-maximum suppression along the quantized gradient direction, double thresholding, and bounded hysteresis relaxation. Pixels at or above high_threshold are strong edges; pixels at or above low_threshold are weak and are kept only when 8-connected to a strong edge. hysteresis_passes bounds the relaxation passes (edge chains longer than the bound are cut); zero selects height + width per plane. Output planes carry 1.0 on detected edges and 0.0 elsewhere. Errors Returns an error unless the image is a nonempty FP32 NCHW/CHW image and both thresholds are finite with 0 <= low_threshold <= high_threshold.
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 clahe( input: &Image, clip_limit: f32, tile_width: u32, tile_height: u32 ) -> Result<Image>
Contrast-limited adaptive histogram equalization per plane. Each plane is split into tile_width x tile_height tiles, quantized into 256 uniform buckets over [0, 1], clipped at clip_limit times the per-bin average with the excess spread uniformly, and remapped through bilinear-interpolated tile lookup tables following the CLAHE contract. Errors Returns an error unless the image is nonempty FP32 NCHW/CHW, clip_limit is finite and positive, both tile extents are nonzero, and all sizes fit the shader ABI.
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 compare_hist( first: &Matrix, second: &Matrix, method: HistogramComparison ) -> Result<Matrix>
Compare two same-shape U32 histogram matrices row by row. The last dimension is the bucket axis; every leading index is an independent row, so [B,C,bins] histograms produce a [B,C] FP32 score matrix. Correlation, chi-square, intersection, and Bhattacharyya follow the OpenCV compareHist formulas; degenerate rows return 0.0 rather than propagating a zero denominator. Errors Returns an error unless both inputs are same-shape nonempty U32 matrices of rank at least two on one runtime, and all sizes fit the shader ABI.
pub fn composite( left: &Image, right: &Image, mask: &Image ) -> Result<Image>
Composite two equal images with a clamped Gray or per-channel mask.
pub fn connected_components( input: &Image, threshold: f32, connectivity: Connectivity, propagation_passes: u32 ) -> Result<Matrix>
Connected-component labeling per plane, following connectedComponents: every pixel above threshold is a foreground candidate and receives a unique initial label; bounded min-label propagation merges neighbors under the selected connectivity (4 or 8). The U32 output carries plane x height x width labels with u32::MAX on background pixels. propagation_passes bounds label propagation (zero selects height + width per plane); components with diameters beyond the bound resolve to sub-components. Errors Returns an error unless the image is a nonempty FP32 NCHW/CHW image and threshold is finite.
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 corner_fast( input: &Image, arc_length: u32 ) -> Result<Image>
FAST corner response per plane on the radius-3 circle of 16 samples: for each pixel the score is the largest deviation t such that arc_length contiguous circle samples are all brighter than center + t or all darker than center - t, zero when no such arc exists. Pixels within 3 of the border score 0.0. The response map shares the input geometry; non-maximum suppression and thresholding select candidate keypoints. Errors Returns an error unless the image is a nonempty FP32 NCHW/CHW image and arc_length is in 9..=16.
pub fn corner_score( input: &Image, block_size: u32, k: f32, score_type: CornerScore ) -> Result<Image>
Per-pixel corner response over each plane: 3x3 Sobel gradients feed windowed second moments M = [sum Ix^2, sum IxIy; sum IxIy, sum Iy^2] inside a block_size x block_size box. Harris emits det(M) - k * trace(M)^2; MinEigen emits the smaller eigenvalue of M (Shi-Tomasi). Borders reflect101 like cornerHarris. The response map shares the input geometry; combine with a local max pass for candidate keypoints. Errors Returns an error unless the image is a nonempty FP32 NCHW/CHW image, k is finite, and block_size is odd and at least 3.
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 cvt_color( input: &Image, conversion: ColorConversion ) -> Result<Image>
Convert an FP32 image between color spaces following cvtColor. The conversion code owns the color-space contract, matching OpenCV’s COLOR_* pairs: channel-ordered inputs admit the Rgb/Bgr sources and Gray admits the gray sources. The output carries Gray for luminance results, Rgb for gray-to-color results, and the input format otherwise; the color-space interpretation of three-channel results follows the conversion code exactly as it does for cv::Mat. HSV keeps OpenCV’s F32 ranges (H [0, 360], S/V [0, 1]); Lab uses the D65 XYZ intermediate (L [0, 100], a/b signed); YCrCb applies the F32 0.5 chroma offset. Errors Returns an error unless the image is nonempty FP32 NCHW/CHW and the source channel count matches the conversion.
pub fn decode_file( path: impl AsRef<Path>, format: ImageFormat ) -> Result<Image>
Decode a JPEG, PNG, WebP, BMP, TGA, or TIFF 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. This variant decodes on this thread’s default runtime. An runtime initialization failure is returned before decoding starts.
pub fn decode_file_on( runtime: &Runtime, path: impl AsRef<Path>, format: ImageFormat ) -> Result<Image>
Decode a JPEG, PNG, WebP, BMP, TGA, or TIFF file and upload normalized planar FP32 pixels on a particular runtime. This is the decode_file contract evaluated on runtime instead of this thread’s default runtime. Errors Returns the same errors as decode_file.
pub fn decode_memory( encoded: &[u8], format: ImageFormat ) -> Result<Image>
Decode JPEG, PNG, WebP, BMP, TGA, or TIFF 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. This variant decodes on this thread’s default runtime. An runtime initialization failure is returned before decoding starts.
pub fn decode_memory_on( runtime: &Runtime, encoded: &[u8], format: ImageFormat ) -> Result<Image>
Decode JPEG, PNG, WebP, BMP, TGA, or TIFF bytes and upload normalized planar FP32 pixels on a particular runtime. 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 distance_transform( input: &Image, threshold: f32, distance: DistanceType, propagation_passes: u32 ) -> Result<Matrix>
Distance transform per plane, following distanceTransform: every pixel above threshold measures the chamfer distance to the nearest background pixel. DistanceType::L1 uses a 4-neighborhood with unit weights (exact Manhattan distance); DistanceType::L2 uses an 8-neighborhood with weights 1 / sqrt(2), the classic 3x3 chamfer approximation. The F32 output carries plane x height x width distances, zero on background. propagation_passes bounds the relaxation (zero selects height + width per plane, the worst-case propagation distance). Errors Returns an error unless the image is a nonempty FP32 NCHW/CHW image and threshold is finite.
pub fn draw_circle( input: &Image, cx: f32, cy: f32, radius: f32, color: f32, thickness: f32 ) -> Result<Image>
Draw a circle ring or disk over a copy of the input, following circle: (cx, cy) is the center in pixel units. A positive thickness draws a ring whose band is that many pixels wide around radius; a negative thickness fills the disk. color applies to every plane. Errors Returns an error unless the image is a nonempty FP32 NCHW/CHW image, cx, cy, radius, and color are finite, radius is positive, and thickness is finite and nonzero.
pub fn draw_line( input: &Image, x1: f32, y1: f32, x2: f32, y2: f32, color: f32, thickness: f32 ) -> Result<Image>
Draw a straight segment over a copy of the input, following line: each pixel whose center lies within thickness / 2 of the (x1, y1)-(x2, y2) segment takes color; all other pixels copy the input. Coordinates are continuous pixel units and color applies to every plane. No anti-aliasing is applied. Errors Returns an error unless the image is a nonempty FP32 NCHW/CHW image, all coordinates and color are finite, and thickness is positive and finite.
pub fn draw_rectangle( input: &Image, x: f32, y: f32, width: f32, height: f32, color: f32, thickness: f32 ) -> Result<Image>
Draw a rectangle border or fill over a copy of the input, following rectangle: (x, y) gives the top-left corner in pixel units and width/height the extent. A positive thickness draws a border band that many pixels wide measured inward from the rectangle edge; a nonpositive thickness fills the rectangle. color applies to every plane. Errors Returns an error unless the image is a nonempty FP32 NCHW/CHW image, all coordinates and color are finite, width and height are positive, and thickness is finite and nonzero.
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 equalize_hist( input: &Image ) -> Result<Image>
Equalize a normalized FP32 image histogram per (batch, channel) plane. Pixel values are quantized into 256 uniform buckets over [0, 1], the per-plane cumulative distribution is spread back over [0, 1] following the equalizeHist contract, and the result keeps the input layout and format. Values outside [0, 1] clamp into the edge buckets. Errors Returns an error unless the image is nonempty FP32 NCHW/CHW and all sizes fit the shader ABI.
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 estimate_affine_2d( source: &Matrix, destination: &Matrix ) -> Result<Matrix>
Least-squares estimate the 2x3 affine transform mapping source points to destination points, matching estimateAffine2D without refinement. Both inputs must be [N, 2] F32 matrices with N >= 3 equal rows. Errors Returns an error unless both inputs share an [N, 2] F32 shape with N >= 3 and the normal equations are nonsingular.
pub fn fast_nl_means_denoising( input: &Image, h: f32, template_window: u32, search_window: u32 ) -> Result<Image>
Non-local means denoising over a search window, following cv::fastNlMeansDenoising. Each output pixel is the weighted mean of samples in the (search_window)^2 neighbourhood with weights exp(-d / h^2), where d is the patch SSD over an odd template_window normalized by its area; the center weight equals the largest neighbour weight so a uniform region stays untouched. Returns an image with identical shape, layout, and format. Errors Returns an error unless input is a nonempty FP32 NCHW/CHW image, h is finite and positive, and both windows are odd and at least 3.
pub fn fill_polygon( input: &Image, points: &Matrix, color: f32 ) -> Result<Image>
Fill a polygon over a copy of the input, following fillPoly: the points matrix carries [N, 2] vertex coordinates and every pixel whose center falls inside the even-odd winding of the polygon takes color. color applies to every plane. Errors Returns an error unless the image is a nonempty FP32 NCHW/CHW image, points is an FP32 [N, 2] matrix with at least 3 vertices on the same runtime, and color is finite.
pub fn find_contours( input: &Image, threshold: f32, connectivity: Connectivity, max_contours: u32, max_points: u32, propagation_passes: u32, ) -> Result<( Matrix, Matrix )>
External contour extraction per plane, following findContours with RETR_EXTERNAL semantics: foreground pixels above threshold are labeled as connected components under the selected connectivity, each component’s minimum-index boundary pixel seeds a Moore-neighbor trace that emits an ordered (x, y) point list. Returns an F32 [planes, max_contours, max_points, 2] point matrix and a U32 [planes, max_contours] length matrix; unused slots stay zero. max_points bounds each contour (zero selects 4 * (height + width); longer contours truncate), and max_contours bounds the per-plane contour count. propagation_passes bounds component labeling (zero selects height + width). Contour order and slot assignment are unspecified across planes. Errors Returns an error unless the image is a nonempty FP32 NCHW/CHW image, threshold is finite, and max_contours is nonzero.
pub fn flip( input: &Image, horizontal: bool, vertical: bool ) -> Result<Image>
Flip an image horizontally, vertically, or along both axes.
pub fn flood_fill( input: &Image, seed_x: u32, seed_y: u32, value: f32, lo_diff: f32, up_diff: f32, connectivity: Connectivity, propagation_passes: u32 ) -> Result<Image>
Floating-range flood fill per plane, following floodFill: the pixel at (seed_x, seed_y) takes value, and each unmarked pixel joins the region when a connected neighbor already belongs and the candidate’s original value lies within [neighbor - lo_diff, neighbor + up_diff] of that neighbor’s original value. Propagation runs a fixed number of relaxation passes (zero selects height + width); regions whose flood diameter exceeds the bound fill partially. The output is a filled copy of the input; unmarked pixels keep their values. Errors Returns an error unless the image is a nonempty FP32 NCHW/CHW image, the seed is in bounds, and value, lo_diff, and up_diff are finite with lo_diff >= 0 and up_diff >= 0.
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 good_features_to_track( input: &Image, max_corners: u32, quality: f32, min_distance: f32, ) -> Result<( Matrix, Matrix )>
Bounded goodFeaturesToTrack selection over a per-plane corner response map: pixels scoring above quality * plane_max survive radius suppression when no strictly stronger candidate lies within min_distance (ties break by lower linear index). Survivors claim atomic slots per plane up to max_corners; slot order is unsorted unlike OpenCV’s score-descending emission. Returns (keypoints, counts): an F32 [planes, max_corners, 3] matrix of (x, y, score) rows holding min(count, max_corners) valid entries followed by zeros, and a U32 [planes] survivor count matrix (may exceed max_corners when slots truncate). A max_corners of zero selects height * width per plane. Errors Returns an error unless the image is a nonempty FP32 NCHW/CHW image and both quality and min_distance are finite with quality in [0, 1] and min_distance >= 0.
pub fn grayscale( input: &Image ) -> Result<Image>
Convert an RGB or RGBA image to Rec.709 grayscale.
pub fn hough_lines( input: &Image, edge_threshold: f32, rho_step: f32, theta_step: f32, threshold: u32, max_lines: u32 ) -> Result<Matrix>
Standard Hough line transform per plane, following HoughLines: pixels above edge_threshold vote into a (theta x rho) accumulator quantized by theta_step (degrees over [0, 180)) and rho_step. Accumulator cells reaching threshold votes that are strict local maxima in their 3x3 theta-rho neighborhood emit lines. The F32 output carries plane x max_lines x 3 rows of (rho, theta degrees, votes) in compacted unsorted order; unused rows are zero. Errors Returns an error unless the image is a nonempty FP32 NCHW/CHW image, edge_threshold/rho_step/theta_step are finite, rho_step/theta_step are positive, theta_step does not exceed 180, and max_lines is nonzero.
pub fn hough_lines_p( input: &Image, edge_threshold: f32, rho_step: f32, theta_step: f32, threshold: u32, max_lines: u32, min_line_length: f32, max_line_gap: u32 ) -> Result<Matrix>
Probabilistic Hough segment transform per plane, following HoughLinesP: votes accumulate as in hough_lines, strict local-maxima cells above threshold emit candidate lines, and each candidate is walked along its direction to find the dominant contiguous edge run that tolerates gaps of up to max_line_gap pixels and reaches min_line_length. The F32 output carries plane x max_lines x 4 rows of (x1, y1, x2, y2) endpoints; line slots without a qualifying run are zero. Errors Returns an error unless the image is a nonempty FP32 NCHW/CHW image, edge_threshold/rho_step/theta_step are finite, rho_step/theta_step are positive, theta_step does not exceed 180, min_line_length is nonnegative, and max_lines is nonzero.
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 integral( input: &Image ) -> Result<Matrix>
Compute the per-plane summed-area table of an FP32 image. Following the integral contract, the result is a (height + 1) x (width + 1) FP32 Matrix per (batch, channel) plane whose zero row and column border the inclusive prefix sums: element (y, x) holds the sum over source pixels [0, y) x [0, x). The leading dimensions are preserved ahead of the enlarged spatial extents. Errors Returns an error unless the image is nonempty FP32 NCHW/CHW, enlarged extents stay nonzero, and all sizes fit the shader ABI.
pub fn invert( input: &Image, max_value: f32 ) -> Result<Image>
Invert every value around max_value.
pub fn invert_affine( matrix: &Matrix ) -> Result<Matrix>
Invert a 2x3 affine transform matrix, matching invertAffineTransform. The input must be a [2, 3] F32 matrix with a nonsingular linear block. Errors Returns an error unless matrix is a [2, 3] F32 matrix whose 2x2 linear block is nonsingular.
pub fn laplacian( input: &Image, border: BorderMode ) -> Result<Image>
Apply the four-neighbor discrete Laplacian.
pub fn match_template( input: &Image, template: &Image, method: MatchTemplate ) -> Result<Matrix>
Slide a single-plane template over each image plane and write the per-position match score to a Matrix, following matchTemplate. The template’s channel count must equal the input’s; the output carries the input’s leading plane dimensions plus (height - th + 1) x (width - tw + 1) score elements computed by a serial per-position reduction over the template window. Errors Returns an error unless both images are nonempty FP32 NCHW/CHW images with matching channel counts, a single-plane template no larger than the image planes, and sizes that fit the shader ABI.
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 moments( input: &Image ) -> Result<Matrix>
Compute the ten spatial moments m00, m10, m01, m20, m11, m02, m30, m21, m12, m03 per image plane through a serial per-plane reduction, following cv::moments. The result Matrix carries the image’s leading plane dimensions plus a final extent-10 moment dimension. Errors Returns an error unless the image is a nonempty FP32 NCHW/CHW image and all sizes fit the shader ABI.
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 noise_like( input: &Image, distribution: NoiseDistribution, amplitude: f32, seed: u64 ) -> Result<Image>
Generate deterministic Philox noise matching input’s shape and layout. The same (seed, distribution, amplitude) triple always produces the same noise tensor. The result carries input’s layout and format so it can be mixed back into the image or an augmentation chain. Errors Returns an error when amplitude is negative or non-finite, or noise generation/allocation fails.
pub fn normalize( input: &Image, parameters: NormalizationConfig ) -> Result<Image>
Apply (pixel - mean[channel]) / std[channel] to up to three channels.
pub fn optical_flow_farneback( previous: &Image, next: &Image, levels: u32, window: u32, iterations: u32, poly_n: u32, poly_sigma: f32 ) -> Result<Matrix>
Dense Farneback optical flow over a 2x image pyramid, following calcOpticalFlowFarneback. Each level expands both frames into polynomial coefficient maps through two separable weighted-least-squares passes (flow_expand_v then flow_expand_h), then relaxes the flow field with iterations Jacobi flow_update dispatches over a 2 * window + 1 averaging neighbourhood. The coarsest level starts from a zero field; finer levels initialize from the 2x-upsampled coarser solution. window is the half-window radius of the update averaging neighbourhood and poly_n the half-support of the gaussian-weighted polynomial fit. Returns the F32 [planes, 2, H, W] flow field at level-0 resolution with x displacement in channel 0 and y displacement in channel 1. Errors Returns an error unless both images are nonempty FP32 NCHW/CHW images with identical shape, layout, and format, levels, window, iterations, and poly_n are >= 1, poly_sigma is finite and positive, and the coarsest level still fits the polynomial support.
pub fn optical_flow_pyr_lk( previous: &Image, next: &Image, points: &Matrix, levels: u32, window: u32, iterations: u32, min_eigen: f32, ) -> Result<( Matrix, Matrix, Matrix )>
Sparse Lucas-Kanade optical flow with image pyramids, following calcOpticalFlowPyrLK. Each pyramid level runs one flow_lk_refine dispatch from the coarsest level to level 0 over 2 * window + 1 windows with the same point set applied to every image plane; the tracked estimate carries between levels in a [planes, N, 2] state buffer and the last level writes status and error maps. points is an F32 [N, 2] matrix of (x, y) source positions in level-0 pixel coordinates. window is the half-window radius. Returns (next_points, status, error): the tracked F32 [planes, N, 2] positions, an F32 [planes, N] found/lost mask, and an F32 [planes, N] RMS patch-residual error; status 0 rows carry the final unconverged estimate. Errors Returns an error unless both images are nonempty FP32 NCHW/CHW images with identical shape, layout, and format, points is a nonempty F32 [N, 2] matrix, levels, window, and iterations are >= 1, min_eigen is finite and positive, and the coarsest level still fits the full window.
pub fn orb( input: &Image, max_features: u32, quality: f32, min_distance: f32, levels: u32, edge: u32, ) -> Result<( Matrix, Matrix, Matrix )>
Bounded ORB keypoint + steered rBRIEF descriptor pipeline, following ORB::detectAndCompute. Each pyramid level runs the existing corner_fast + good_features_to_track stages (FAST-9 response, quality-thresholded radius suppression), then a describe stage computes the intensity-centroid orientation over a 31x31 patch and a 256-bit steered BRIEF descriptor using the OpenCV bit_pattern_31_ test pairs. Scale factor is 2x per level via pyr_down. Returns (keypoints, descriptors, counts): an F32 [planes, max_features, 6] matrix of (x, y, angle_radians, score, level, size) rows in level-0 coordinates, a U32 [planes, max_features, 8] matrix of descriptor words, and a U32 [planes] claimed-slot count (may exceed max_features). Slot order is unordered across a level’s survivors. A max_features of zero selects height * width per plane. Errors Returns an error unless the image is a nonempty FP32 NCHW/CHW image, levels >= 1, edge >= 18 (rotated test-pair support), quality is in [0, 1], and min_distance is finite and >= 0.
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 perspective_transform( source: &Matrix, destination: &Matrix ) -> Result<Matrix>
Solve the 3x3 perspective transform mapping four [x, y] source points to four destination points, matching getPerspectiveTransform. Both inputs must be [4, 2] F32 matrices. Errors Returns an error unless both inputs are [4, 2] F32 matrices yielding a nonsingular 8x8 system (no three collinear source points).
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 psnr( first: &Image, second: &Image, peak_value: f32 ) -> Result<Matrix>
Peak signal-to-noise ratio per image plane in decibels, following cv::PSNR: 10 * log10(peak^2 / mse) through a serial per-plane reduction, +inf when the planes match exactly. The result Matrix carries the image’s leading plane dimensions. Errors Returns an error unless both images are nonempty FP32 NCHW/CHW images with identical shape, layout, and format and peak_value is finite and positive.
pub fn pyr_down( input: &Image ) -> Result<Image>
Halve an FP32 image with the pyrDown Gaussian-decimate contract. Each output pixel gathers the 5x5 [1, 4, 6, 4, 1] Gaussian neighborhood centered on the doubled source coordinate, following OpenCV’s BORDER_DEFAULT (reflect-101) edge rule. Output spatial extents are (extent + 1) / 2 per axis; layout and format are preserved. Errors Returns an error unless the image is nonempty FP32 NCHW/CHW and all sizes fit the shader ABI.
pub fn pyr_mean_shift_filtering( input: &Image, sp: f32, sr: f32, max_level: u32 ) -> Result<Image>
Pyramid mean-shift edge-preserving smoothing, following cv::pyrMeanShiftFiltering. The image is downsampled max_level times with pyr_down; each level then runs a per-pixel mean-shift pass that, for up to five iterations, averages the (2*sp+1)^2 window samples whose channel-vector distance stays below sr and adopts that mean position and color, converging when the spatial shift drops under one pixel. Coarse-to-fine levels seed their starting color from the parent’s converged result. Channels participate as one color vector per plane pixel; returns an image with identical shape, layout, and format. Errors Returns an error unless input is a nonempty FP32 NCHW/CHW image with at most 4 channels, sp/sr are finite and positive, max_level is in [1, 4], and the coarsest level still fits the spatial window support.
pub fn pyr_up( input: &Image ) -> Result<Image>
Double an FP32 image with the pyrUp interpolate-blur contract. The source is upsampled by two with zero rows and columns at odd positions, then convolved with the 5x5 [1, 4, 6, 4, 1] kernel scaled by four, following OpenCV’s BORDER_DEFAULT (reflect-101) edge rule on the upsampled grid. Output spatial extents are 2 * extent per axis; layout and format are preserved. Errors Returns an error unless the image is nonempty FP32 NCHW/CHW and all sizes fit the shader ABI.
pub fn random_crop( input: &Image, width: u32, height: u32, seed: u64 ) -> Result<Image>
Crop a width×height window at a seed-derived uniform offset. The offset is drawn uniformly over the valid top-left range from seed, keeping the crop itself a single recorded device operation. Errors Returns an error when the window is zero-sized or exceeds input, or the crop fails.
pub fn random_flip( input: &Image, p_horizontal: f32, p_vertical: f32, seed: u64 ) -> Result<Image>
Randomly mirror input horizontally and/or vertically. p_horizontal and p_vertical are independent probabilities in [0, 1]. Both coin draws are derived from seed, so the same recipe flips the same way on every run. Errors Returns an error when either probability is outside [0, 1] or non-finite, or the flip fails.
pub fn random_rotate( input: &Image, seed: u64 ) -> Result<Image>
Rotate input by a seed-derived quarter-turn: 0°, 90°, 180°, or 270°. Errors Returns the rotation error when dispatch fails.
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 reproject_image_to_3d( disparity: &Matrix, q: &Matrix ) -> Result<Matrix>
Per-pixel reprojection of a disparity map into 3D coordinates, following cv::reprojectImageTo3D. For each pixel it evaluates (X, Y, Z, W) = Q * [x, y, disparity, 1] with the row-major 4x4 F32 matrix q, then writes the normalized coordinates X/W, Y/W, Z/W. disparity must be F32 [planes, 1, H, W] (the stereo_bm output layout) and q F32 [4, 4]; the homogeneous divide is unguarded, so a degenerate last row surfaces as inf/NaN. Returns the F32 [planes, 3, H, W] coordinate map. Errors Returns an error unless disparity is F32 with shape [planes, 1, H, W] and q is F32 [4, 4] on the same runtime.
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. Area performs a coverage-weighted box average for downscales and pixel replication for upscales, matching INTER_AREA. Cubic uses the Keys a=-0.75 bicubic kernel over the 4x4 source neighborhood, and Lanczos uses the a=4 sinc kernel over the 8x8 source neighborhood with the filter widened by the inverse scale when downscaling, matching INTER_CUBIC and INTER_LANCZOS4. 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: NormalizationConfig ) -> 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 rotation_matrix_2d( center_x: f32, center_y: f32, angle: f32, scale: f32 ) -> Result<Matrix>
Build the 2x3 rotation+scale matrix mapping about center, matching getRotationMatrix2D: alpha = scale * cos(angle), beta = scale * sin(angle) with angle in degrees counterclockwise. Errors Returns an error when any parameter is non-finite.
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 ssim( first: &Image, second: &Image ) -> Result<Matrix>
Global structural similarity per image plane through a serial per-plane reduction of means, variances, and covariance with the standard K1=0.01, K2=0.03 constants over a [0, 1] dynamic range, following the SSIM index of Wang et al. rather than OpenCV’s windowed map. The result Matrix carries the image’s leading plane dimensions. Errors Returns an error unless both images are nonempty FP32 NCHW/CHW images with identical shape, layout, and format.
pub fn stereo_bm( left: &Image, right: &Image, num_disparities: u32, block_size: u32, uniqueness: u32 ) -> Result<Matrix>
Block-matching stereo disparity over the horizontal search range [0, num_disparities), following cv::StereoBM. The stereo_sad pass builds a [planes, num_disparities, H, W] sum-of-absolute-differences volume over an odd block_size window; stereo_wta then keeps the per-pixel argmin, applies the uniqueness percent runner-up margin test (0 disables), and refines the winner with a symmetric parabola on the neighbouring costs. Pixels outside the border region where the matching window fits for every disparity, and uniqueness losers, are marked -1; the valid range otherwise starts at 0. Returns the F32 [planes, 1, H, W] disparity map. Errors Returns an error unless both images are nonempty FP32 NCHW/CHW images with identical shape, layout, and format, num_disparities >= 1, block_size is odd and >= 3, and the image fits the combined block and disparity support.
pub fn threshold_auto( input: &Image, method: AutoThreshold, max_value: f32, ) -> Result<( Image, Matrix )>
Binary-threshold an FP32 image with a histogram-selected level. Each (batch, channel) plane is quantized into 256 uniform buckets over [0, 1]; the Otsu or Triangle method selects one threshold per plane following the OpenCV THRESH_OTSU/THRESH_TRIANGLE contracts, and pixels strictly above it produce max_value while all others produce 0.0. Returns the thresholded image together with the per-plane threshold Matrix shaped like the leading dimensions. Errors Returns an error unless the image is nonempty FP32 NCHW/CHW, max_value is finite, and all sizes fit the shader ABI.
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.
pub fn warp_polar( input: &Image, center_x: f32, center_y: f32, max_radius: f32, out_width: u32, out_height: u32, mode: PolarMode, interpolation: InterpolationMode, border: BorderMode, border_value: f32 ) -> Result<Image>
Warp each image plane to polar coordinates about a center, following warpPolar: output row y is the angular axis [0, 2pi) and column x is the radial axis — x / width * max_radius under Linear or max_radius^(x / width) under SemiLog. Source samples gather with the admitted interpolation and border policy. Errors Returns an error unless the image is a nonempty FP32 NCHW/CHW image, the center and radius are finite with max_radius > 0, the output extent is nonzero, border_value is finite, and all sizes fit the shader ABI.