Segment objects in images using SAM with simple point and box prompts instead of manual pixel-level labeling.
Manually labeling object boundaries pixel by pixel is time-consuming and error-prone. This app lets you segment objects by simply clicking points or drawing bounding boxes, using the Segment Anything Model (SAM) to infer precise boundaries automatically.
Users can apply foreground/background point prompts and bounding boxes to generate segmentation masks with live preview, commit masks to labeled outputs, and export results to files or the MATLAB workspace. The app uses extractEmbeddings and segmentObjectsFromEmbeddings from the SAM support package.
Requires MATLAB® R2026b or newer.
Also requires the following MathWorks products:
- Image Processing Toolbox™
The following support packages must also be installed (available via MATLAB Add-On Explorer):
- Image Processing Toolbox™ Model for Segment Anything Model 2
Open SAMSegmentationApp.m in App Designer or see the guided walkthrough on the documentation page.
| File | Description |
|---|---|
SAMSegmentationApp.m |
The App Designer app for SAM-based image segmentation |
SAMSegmentationApp.xml |
App component layout data |
SAMSegmenter.mlapp |
UI component used by the app |
The license is available in the license.txt file in this GitHub repository.
Copyright 2026 The MathWorks, Inc.
