segmentObjectsFromEmbeddings
Segment objects in image using Segment Anything Model (SAM) feature embeddings
Since R2024a
Syntax
Description
Add-On Required: This feature requires one of these add-ons.
segments objects from an image of size masks = segmentObjectsFromEmbeddings(sam,embeddings,imageSize,ForegroundPoints=pointPrompt)imageSize using the SAM feature
embeddings embeddings and the foreground point coordinates
pointPrompt as a visual prompt.
segments objects from an image using bounding box coordinates masks = segmentObjectsFromEmbeddings(sam,embeddings,imageSize,BoundingBox=boxPrompt)boxPrompt
as a visual prompt.
specifies options using one or more name-value arguments in addition to any combination of
input arguments from previous syntaxes. For example, masks = segmentObjectsFromEmbeddings(___,Name=Value)ReturnMultiMask=true
returns three masks for a segmented object.
[
returns the scores corresponding to each predicted object mask and the prediction mask
logits masks,scores,maskLogits] = segmentObjectsFromEmbeddings(___)maskLogits, using any combination of input arguments from
previous syntaxes.
Note
To use any of the SAM 2 models, this functionality requires the Image Processing Toolbox™ Model for Segment Anything Model 2 add-on if you use any of the SAM 2 models. To use the base SAM model, this functionality requires the Image Processing Toolbox Model for Segment Anything Model add-on.
Examples
Input Arguments
Name-Value Arguments
Output Arguments
References
[1] Kirillov, Alexander, Eric Mintun, Nikhila Ravi, Hanzi Mao, Chloe Rolland, Laura Gustafson, Tete Xiao, et al. "Segment Anything," April 5, 2023. https://doi.org/10.48550/arXiv.2304.02643.
[2] Ravi, Nikhila, Valentin Gabeur, Yuan-Ting Hu, Ronghang Hu, Chaitanya Ryali, Tengyu Ma, Haitham Khedr, et al. “SAM 2: Segment Anything in Images and Videos.” arXiv, October 28, 2024. https://doi.org/10.48550/arXiv.2408.00714.
Version History
Introduced in R2024a


