Skip to main content

Crate outline

Crate outline 

Source
Expand description

§Outline

Image background removal with flexible mask processing options.

Powered by ONNX Runtime (ort) and VTracer, and works with U2-Net, BiRefNet, and other ONNX models with a compatible input/output shape.

§Quick Start

use outline::Outline;

let outline = Outline::new("model.onnx");
let session = outline.for_image("input.png")?;
let matte = session.matte();

// Compose the foreground directly from the raw matte (soft edges)
let foreground = matte.foreground()?;
foreground.save("foreground.png")?;

// Process the mask and save it
let mask = matte.blur().threshold().processed()?;
mask.save("mask.png")?;

Structs§

ForegroundHandle
Composed RGBA foreground image with transparent background.
InferenceSettings
Configuration for ONNX model inference and image preprocessing.
InferencedMatte
Inference result containing the original RGB image and raw matte prediction.
MaskHandle
Processed mask image with optional further refinement and output generation.
MaskProcessingOptions
Configuration for mask post-processing operations.
MatteHandle
Builder for chaining mask processing operations on the raw matte.
Outline
Entry point for configuring and running background matting inference.
TraceOptionsvectorizer-vtracer
Configuration for vectorizing masks into SVG paths using VTracer.
VtracerSvgVectorizervectorizer-vtracer
Converts grayscale masks to SVG using the VTracer library.

Enums§

OutlineError
Error types that can occur during outline processing.

Constants§

DEFAULT_MODEL_PATH
Default model path used when no explicit path is provided.
ENV_MODEL_PATH
Environment variable name for specifying the model path.

Traits§

MaskVectorizer
A trait representing an algorithm that can turn a mask into a vector representation.

Functions§

trace_to_svg_stringvectorizer-vtracer
The helper function that uses VTracer to trace a grayscale mask to an SVG string.

Type Aliases§

OutlineResult
Result type alias for operations that may fail with OutlineError.