segmentObjectsFromEmbeddings
Segment objects in image using Segment Anything Model (SAM) feature embeddings
Since R2024a
Syntax
Description
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.
Note
This functionality requires Deep Learning Toolbox™, Computer Vision Toolbox™, and the Image Processing Toolbox™ Model for Segment Anything Model. You can install the Image Processing Toolbox Model for Segment Anything Model from Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.
[
segments objects from an image using bounding box coordinates
masks
] = segmentObjectsFromEmbeddings(sam
,embeddings
,imageSize
,BoundingBox=boxPrompt
)boxPrompt
as a visual prompt.
[
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.
[___] = segmentObjectsFromEmbeddings(___,
specifies options using one or more name-value arguments in addition to any combination of
arguments from previous syntaxes. For example, Name=Value
)ReturnMultiMask=true
specifies to return three masks for a segmented object.
Examples
Input 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.
Version History
Introduced in R2024a
See Also
segmentAnythingModel
| extractEmbeddings
Topics
- Get Started with Segment Anything Model for Image Segmentation
- Deep Learning in MATLAB (Deep Learning Toolbox)