Skip to main content
Version: Next

Function: selectByPoint()

selectByPoint<L>(instances, x, y): SegmentedInstance<L> | null

Defined in: utils/segmentAnythingPrompts.ts:16

Selects the best matching instance for a given point prompt.

Finds all instances whose mask covers the point (x, y), then returns the one with the smallest bounding box area (ties broken by highest confidence).

Type Parameters

L

L extends Readonly<Record<string, string | number>>

Parameters

instances

SegmentedInstance<L>[]

Array of segmented instances returned by forward().

x

number

X coordinate in original image space.

y

number

Y coordinate in original image space.

Returns

SegmentedInstance<L> | null

The best matching instance, or null if no mask covers the point.