Geometry and mask functions

This page is generated automatically from the interpreter function registry and grouped by practical use.

Page map

Geometry functions 16

RECT.AREA

FUNCTIONRECTBATCH-FRIENDLY
Kind: Function   Category: Geometry functions   Namespace: RECT

RECT.AREA(rect)

Returns w*h for valid rectangles, otherwise 0.

Minimal example

value = RECT.AREA(rect)

RECT.CLIP

FUNCTIONRECTBATCH-FRIENDLY
Kind: Function   Category: Geometry functions   Namespace: RECT

RECT.CLIP(rect, width, height)

Clips a rectangle to image bounds [0,width) x [0,height).

Minimal example

value = RECT.CLIP(rect, width, height)

RECT.CREATE

FUNCTIONRECTBATCH-FRIENDLY
Kind: Function   Category: Geometry functions   Namespace: RECT

RECT.CREATE(x, y, w, h)

Creates a half-open pixel rectangle represented by x,y,w,h. XEND is x+w and YEND is y+h.

Minimal example

r = RECT.CREATE(10, 20, 30, 40)

RECT.EMPTY

FUNCTIONRECTBATCH-FRIENDLY
Kind: Function   Category: Geometry functions   Namespace: RECT

RECT.EMPTY(rect)

Returns TRUE when rect has zero/negative width or height.

Minimal example

value = RECT.EMPTY(rect)

RECT.EQUAL

FUNCTIONRECTBATCH-FRIENDLY
Kind: Function   Category: Geometry functions   Namespace: RECT

RECT.EQUAL(a, b)

Returns TRUE when x,y,w,h are identical.

Minimal example

value = RECT.EQUAL(a, b)

RECT.FROM_TEXT

FUNCTIONRECTBATCH-FRIENDLY
Kind: Function   Category: Geometry functions   Namespace: RECT

RECT.FROM_TEXT(text)

Reads a rectangle from RECT(x,y,w,h), RECT:x,y,w,h, or plain x,y,w,h text.

Minimal example

r2 = RECT.FROM_TEXT(RECT.TO_TEXT(r))

RECT.H

FUNCTIONRECTBATCH-FRIENDLY
Kind: Function   Category: Geometry functions   Namespace: RECT

RECT.H(rect)

Returns the rectangle height in pixels.

Minimal example

value = RECT.H(rect)

RECT.INTERSECT

FUNCTIONRECTBATCH-FRIENDLY
Kind: Function   Category: Geometry functions   Namespace: RECT

RECT.INTERSECT(a, b)

Returns the half-open intersection of two rectangles, or an empty rectangle when they do not overlap.

Minimal example

value = RECT.INTERSECT(a, b)

RECT.TO_TEXT

FUNCTIONRECTBATCH-FRIENDLY
Kind: Function   Category: Geometry functions   Namespace: RECT

RECT.TO_TEXT(rect)

Serializes a rectangle as RECT(x,y,w,h).

Minimal example

value = RECT.TO_TEXT(rect)

RECT.UNION

FUNCTIONRECTBATCH-FRIENDLY
Kind: Function   Category: Geometry functions   Namespace: RECT

RECT.UNION(a, b)

Returns the smallest half-open rectangle containing both valid rectangles.

Minimal example

value = RECT.UNION(a, b)

RECT.VALID

FUNCTIONRECTBATCH-FRIENDLY
Kind: Function   Category: Geometry functions   Namespace: RECT

RECT.VALID(rect)

Returns TRUE when rect has strictly positive width and height.

Minimal example

value = RECT.VALID(rect)

RECT.W

FUNCTIONRECTBATCH-FRIENDLY
Kind: Function   Category: Geometry functions   Namespace: RECT

RECT.W(rect)

Returns the rectangle width in pixels.

Minimal example

value = RECT.W(rect)

RECT.X

FUNCTIONRECTBATCH-FRIENDLY
Kind: Function   Category: Geometry functions   Namespace: RECT

RECT.X(rect)

Returns the first included X pixel coordinate.

Minimal example

value = RECT.X(rect)

RECT.XEND

FUNCTIONRECTBATCH-FRIENDLY
Kind: Function   Category: Geometry functions   Namespace: RECT

RECT.XEND(rect)

Returns the exclusive end X coordinate x+w.

Minimal example

value = RECT.XEND(rect)

RECT.Y

FUNCTIONRECTBATCH-FRIENDLY
Kind: Function   Category: Geometry functions   Namespace: RECT

RECT.Y(rect)

Returns the first included Y pixel coordinate.

Minimal example

value = RECT.Y(rect)

RECT.YEND

FUNCTIONRECTBATCH-FRIENDLY
Kind: Function   Category: Geometry functions   Namespace: RECT

RECT.YEND(rect)

Returns the exclusive end Y coordinate y+h.

Minimal example

value = RECT.YEND(rect)

Mask geometry functions 11

MASK.APPLY

FUNCTIONMASKBATCH-FRIENDLY
Kind: Function   Category: Mask geometry functions   Namespace: MASK

MASK.APPLY(image,mask[,background])

Returns image/stack pixels inside the mask unchanged and replaces outside pixels with background. Single images/masks broadcast across stacks.

Optional parameters

Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.

ParameterMeaning
backgroundInitial canvas background value.

Minimal example

inside = MASK.APPLY(img, mask, 0)

MASK.AREA

FUNCTIONMASKBATCH-FRIENDLY
Kind: Function   Category: Mask geometry functions   Namespace: MASK

MASK.AREA(mask)

Alias-style semantic count of foreground pixels. For a rectangular single-frame mask it equals RECT.AREA(rect).

Minimal example

ASSERT MASK.AREA(mask) = RECT.AREA(r), "area mismatch"

MASK.BBOX

FUNCTIONMASKBATCH-FRIENDLY
Kind: Function   Category: Mask geometry functions   Namespace: MASK

MASK.BBOX(mask[,frame])

Returns the half-open RECT bounding box of all non-zero mask pixels in the selected frame.

Optional parameters

Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.

ParameterMeaning
frameZero-based frame index; some stack commands accept -1 for all frames.

Minimal example

r = MASK.BBOX(mask)

MASK.COUNT

FUNCTIONMASKBATCH-FRIENDLY
Kind: Function   Category: Mask geometry functions   Namespace: MASK

MASK.COUNT(mask)

Counts foreground pixels, where any non-zero channel marks a foreground pixel. For stacks, counts all frames.

Minimal example

n = MASK.COUNT(mask)

MASK.COUNT_NONZERO

FUNCTIONMASKBATCH-FRIENDLY
Kind: Function   Category: Mask geometry functions   Namespace: MASK

MASK.COUNT_NONZERO(mask)

Compatibility alias for COUNT_NONZERO / MASK.COUNT.

Minimal example

n = MASK.COUNT_NONZERO(mask)

MASK.EMPTY

FUNCTIONMASKBATCH-FRIENDLY
Kind: Function   Category: Mask geometry functions   Namespace: MASK

MASK.EMPTY(mask)

Returns TRUE if the mask has no foreground pixels.

Minimal example

ASSERT NOT MASK.EMPTY(mask), "mask unexpectedly empty"

MASK.FROM_ROI

FUNCTIONMASKBATCH-FRIENDLYROI
Kind: Function   Category: Mask geometry functions   Namespace: MASK

MASK.FROM_ROI(image[,value])

Creates a mask from the programmatic ROI stored on an image or stack.

Optional parameters

Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.

ParameterMeaning
valueScalar value written, drawn, or used as foreground/background according to the command.

Minimal example

img = ROI.SET_RECT(img, r)
mask = MASK.FROM_ROI(img)

MASK.INVERT

FUNCTIONMASKBATCH-FRIENDLY
Kind: Function   Category: Mask geometry functions   Namespace: MASK

MASK.INVERT(mask)

Returns the binary inverse of a mask, using 0 for foreground and 255 for background.

Minimal example

inv = MASK.INVERT(mask)

MASK.RECT

FUNCTIONMASKBATCH-FRIENDLY
Kind: Function   Category: Mask geometry functions   Namespace: MASK

MASK.RECT(width,height,rect[,value]) OR MASK.RECT(width,height,x,y,w,h[,value])

Creates a binary mask image from a RECT geometry or explicit x,y,w,h coordinates. The rectangle is clipped to the mask bounds.

Optional parameters

Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.

ParameterMeaning
valueScalar value written, drawn, or used as foreground/background according to the command.

Minimal example

r = RECT.CREATE(10,12,20,15)
mask = MASK.RECT(80,60,r)

MASK.TO_ROI

FUNCTIONMASKBATCH-FRIENDLYROI
Kind: Function   Category: Mask geometry functions   Namespace: MASK

MASK.TO_ROI(mask[,frame]) OR MASK.TO_ROI(image,mask[,frame])

With one mask returns MASK.BBOX. With image+mask returns a copy of the image with ROI set to the mask bounding box.

Optional parameters

Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.

ParameterMeaning
frameZero-based frame index; some stack commands accept -1 for all frames.

Minimal example

img2 = MASK.TO_ROI(img, mask)
r = ROI.RECT(img2)

MASK.VALID

FUNCTIONMASKBATCH-FRIENDLY
Kind: Function   Category: Mask geometry functions   Namespace: MASK

MASK.VALID(mask)

Returns TRUE when the argument is a non-empty image/stack that can be treated as a mask.

Minimal example

ASSERT MASK.VALID(mask), "mask not valid"