Skip to content

Repository files navigation

SAM Segmentation App

Segment objects in images using SAM with simple point and box prompts instead of manual pixel-level labeling.

SAM Segmentation App

About This Example

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.

Setup

Products

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

Getting Started

Open SAMSegmentationApp.m in App Designer or see the guided walkthrough on the documentation page.

Example Files

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

License

The license is available in the license.txt file in this GitHub repository.

Community Support

MATLAB Central

Copyright 2026 The MathWorks, Inc.

About

Segment objects in images using SAM with simple point and box prompts instead of manual pixel-level labeling.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages