AddMaskShape

Declaration: AddMaskShape (var MaskArray: TBool2DArray; Shape: TShapeKind; Params: TIntArray): integer;

The function AddMaskShape can be used to create pixel masks based on rectangular, elliptic and circular regions. AddMaskShape sets all matrix cells of the boolean array MaskArray within the selected Shape (including the borders) to TRUE, all other cells are left unchanged. The indices of the matrix are seen as integer coordinates (valid range: 0 <= x < length(MaskArray) and 0 <= y < length(MaskArray[0]).

Depending on the type of the shape the open array parameter Params holds different numbers of parameters. The specific meaning of each parameter can be taken from the following table:

Shape Type Parameters
skRectangle Params[0]: left edge of the rectangle
Params[1]: bottom edge of the rectangle
Params[2]: right edge of the rectangle
Params[3]: top edge of the rectangle
skEllipse Params[0]: left coordinate of bounding rectangle
Params[1]: bottom coordinate of bounding rectangle
Params[2]: right coordinate of bounding rectangle
Params[3]: top coordinate of bounding rectangle
skCircle Params[0]: x coordinate of the circle center
Params[1]: y coordinate of the circle center
Params[2]: radius of the circle

The function returns the following error codes:

 0 ... everything OK
-1 ... invalid number of parameters (depends on the type of the shape, see table above)

Example: The following code snippet resizes the boolean array Mask to 300x300 cells, resets all values to FALSE and sets all matrix cells of a circular region to TRUE values. The center of the region is at cell [100,120], the radius of the circle is 30 pixels:
...
var
  Mask  : TBool2DArray;
...
ResizeBoolMatrix (300,300;
FillBoolArray (Mask, FALSE);
AddMaskShape (Mask, skCircle, [100, 120, 30]);
...

Hint: In order to create an ImageLab mask from the boolean array, you can use the function SetMask to copy the mask data to one of the ImageLab masks.


Last Update: 2017-Dez-04