MaskFromPoints<T>

Models & Types · AiDotNet.Diffusion.MaskUtilities

Generates a mask from point prompts with circular regions, similar to SAM-style point selection.

Implements: IDataTransformer<T, Tensor<T>, Tensor<T>>

For Beginners

Instead of drawing a mask by hand, you can click on points in an image. Each click creates a circular masked area. You can also use negative points to “un-mask” areas within a masked region.

How It Works

Creates a mask by placing circles of a specified radius at each point location. Points can be positive (add to mask) or negative (remove from mask). This mirrors the Segment Anything Model (SAM) point prompt interface.

When used as an IDataTransformer, the Transform method takes an image tensor, uses its dimensions for height/width, and generates a mask from the points configured in the constructor.

Constructors

Constructor Summary
MaskFromPoints(ValueTuple<int, int>[] positivePoints, ValueTuple<int, int>[] negativePoints, int pointRadius) Initializes a new instance of the MaskFromPoints class.

Properties

Property Summary
bool IsFitted { get; }
bool SupportsInverseTransform { get; }
int[] ColumnIndices { get; }

Methods

Method Summary
Tensor<T> FitTransform(Tensor<T> data)
Tensor<T> Generate(int height, int width, ValueTuple<int, int>[] positivePoints, ValueTuple<int, int>[] negativePoints) Generates a mask from positive and negative point prompts.
Tensor<T> InverseTransform(Tensor<T> data)
Tensor<T> Transform(Tensor<T> data) Generates a point mask using the input tensor’s dimensions and the points configured in the constructor.
string[] GetFeatureNamesOut(string[] inputFeatureNames)
void Fit(Tensor<T> data)