Class BackgroundRemovalSettings
- Namespace
- VisioForge.Core.Types.X.AI
- Assembly
- VisioForge.Core.dll
Settings for the background-removal (matting) block/engine.
public class BackgroundRemovalSettings : OnnxInferenceSettingsInheritance
Inherited Members
Remarks
Extends VisioForge.Core.Types.X.AI.OnnxInferenceSettings with the matting VisioForge.Core.Types.X.AI.BackgroundRemovalSettings.Model family and the
background-replacement options. The block runs the ONNX model to estimate a per-pixel foreground alpha
mask and then composites the chosen replacement background where the foreground alpha is low. The
inherited InputWidth/InputHeight apply only to a model with dynamic input dimensions: a model
that bakes in a fixed size reports that size and the configured values are ignored for it. The default
input size is 512x512, which is tuned for VisioForge.Core.Types.X.AI.BackgroundRemovalModel.MODNet and is NOT applied
per-model automatically. For any other dynamic-input model you must set InputWidth/InputHeight
to that model's expected size yourself: 320 for VisioForge.Core.Types.X.AI.BackgroundRemovalModel.U2Net, 1024 for
VisioForge.Core.Types.X.AI.BackgroundRemovalModel.BiRefNet. The pixel normalization (mean/std) is
chosen automatically from VisioForge.Core.Types.X.AI.BackgroundRemovalSettings.Model; VisioForge.Core.Types.X.AI.BackgroundRemovalModel.Custom uses the
inherited NormalizeTo01 flag with no mean/std.
Constructors
BackgroundRemovalSettings()
Initializes a new instance of the VisioForge.Core.Types.X.AI.BackgroundRemovalSettings class.
public BackgroundRemovalSettings()BackgroundRemovalSettings(string)
Initializes a new instance of the VisioForge.Core.Types.X.AI.BackgroundRemovalSettings class with the specified model path.
public BackgroundRemovalSettings(string modelPath)Parameters
modelPathstring-
The absolute path to the matting ONNX model file.
Properties
BackgroundImagePath
Gets or sets the absolute path to the static background image used when VisioForge.Core.Types.X.AI.BackgroundRemovalSettings.ReplacementMode
is VisioForge.Core.Types.X.AI.BackgroundReplacementMode.Image. The image is scaled to the frame size. Defaults to null.
public string BackgroundImagePath { get; set; }Property Value
BlurRadius
Gets or sets the blur radius, in pixels, used when VisioForge.Core.Types.X.AI.BackgroundRemovalSettings.ReplacementMode is VisioForge.Core.Types.X.AI.BackgroundReplacementMode.Blur. Larger values blur the background more. Defaults to 15.
public float BlurRadius { get; set; }Property Value
MaskFeatherAmount
Gets or sets an optional edge-feather radius, in matte (model-resolution) pixels. When greater than 0, the alpha matte is blurred by this radius before compositing, softening the foreground/background transition (useful for hair and motion-blurred edges). A value of 0 (the default) leaves the matte edges as the model produced them. VisioForge.Core.Types.X.AI.BackgroundRemovalSettings.MaskThreshold hardens the edge and feathering softens it; they are opposite controls.
public int MaskFeatherAmount { get; set; }Property Value
MaskThreshold
Gets or sets an optional foreground alpha threshold. The effective range is 0..0.5; values above 0.5 are clamped to 0.5 (the symmetric hardening band only makes sense for thresholds up to the midpoint). Mask values at or below this threshold are forced to full background and values at or above (1 - threshold) to full foreground, hardening the matte edge; the band in between is kept as a soft transition. A value of 0 (the default) keeps the model's raw soft matte unchanged.
public float MaskThreshold { get; set; }Property Value
Model
Gets or sets the matting model family the supplied ONNX model belongs to. This selects the input normalization convention. Defaults to VisioForge.Core.Types.X.AI.BackgroundRemovalModel.MODNet.
public BackgroundRemovalModel Model { get; set; }Property Value
ReplacementColor
Gets or sets the solid background color used when VisioForge.Core.Types.X.AI.BackgroundRemovalSettings.ReplacementMode is VisioForge.Core.Types.X.AI.BackgroundReplacementMode.SolidColor. Defaults to SkiaSharp.SKColors.Green (a virtual green-screen).
public SKColor ReplacementColor { get; set; }Property Value
ReplacementMode
Gets or sets how the background is replaced where the foreground alpha is low. Defaults to VisioForge.Core.Types.X.AI.BackgroundReplacementMode.Blur.
public BackgroundReplacementMode ReplacementMode { get; set; }