MaskFromBoundingBox<T>
Models & Types · AiDotNet.Diffusion.MaskUtilities
Generates a mask from one or more bounding box regions.
Implements: IDataTransformer<T, Tensor<T>, Tensor<T>>
For Beginners
If you have a bounding box around an object (like from an object detector), this utility converts that box into a mask you can use for inpainting or editing that specific region.
How It Works
Creates a binary mask where pixels inside any of the specified bounding boxes are masked (1) and all other pixels are unmasked (0). Useful for region-based inpainting from object detection results.
When used as an IDataTransformer, the Transform method
takes an image tensor, uses its dimensions for height/width, and generates a mask from
the bounding boxes configured in the constructor.
Constructors
| Constructor | Summary |
|---|---|
MaskFromBoundingBox(ValueTuple<int, int, int, int>[] boxes) |
Initializes a new instance of the MaskFromBoundingBox 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, int, int>[] boxes) |
Generates a mask covering the specified bounding boxes. |
Tensor<T> InverseTransform(Tensor<T> data) |
|
Tensor<T> Transform(Tensor<T> data) |
Generates a bounding box mask using the input tensor’s dimensions and the boxes configured in the constructor. |
string[] GetFeatureNamesOut(string[] inputFeatureNames) |
|
void Fit(Tensor<T> data) |