removeObjectsToSegment
R2026bSyntax
Description
The removeObjectsToSegment function removes previously
added objects from a sam2VideoObjectSegmenter object so they are no longer segmented across
video frames. Use this function when an object permanently leaves the scene, becomes
irrelevant to your analysis, or was added by mistake.
After removing objects, call segmentObjects again to update
the segmentation results.
Note
This functionality requires the Image Processing Toolbox™ Model for Segment Anything Model 2 add-on.
removeObjectsToSegment(
removes one or more objects specified by vidSegmenter,objectIDs)objectIDs from being
segmented in all frames. This removes all previously specified object points,
background points, and bounding boxes for the objects in
objectIDs.
removeObjectsToSegment(
removes all prompts for the specified objects only on the frame
vidSegmenter,objectIDs,frameId)frameId. Prompts on other frames remain active.
Examples
Input Arguments
Tips
Remove objects as soon as they permanently leave the scene to free resources and prevent identity drift when processing frames sparsely.
If an object temporarily leaves and re-enters the scene, do not remove it. Instead, use
addObjectsToSegmentwith the same object ID on the re-entry frame to refresh the model memory while preserving identity continuity.
Version History
Introduced in R2026b