A bot to segment foreground from background using a basic blur+threshold+watershed algorithm.
Updated 12 Oct 2017

View License

A bot to segment foreground from background using a basic three-step algorithm:
> blurring
> thresholding
> watershed to split touching objects
Usage: call 'thresholdSegmentationBot' and follow the instructions.

If you have image data already loaded as a double, grayscale, range [0,1] image I,
use thresholdSegmentationTool as in the example below:

I = imread('rice.png');
I = double(I)/255;
I = imtophat(I,strel('disk',12,0')); % background subtraction
TST = thresholdSegmentationTool(I);
% use tool, then click 'Done Setting Parameters'

The final segmentation mask can then be accessed at TST.FinalMask,
and the segmentation model at TST.ThrModel.

The threshold models can be passed to
thresholdSegmentationHeadlessBot for batch processing.

call siameseThresholdSegmentationBot for a version that admits two images side by side.
This can be used to test the same set of parameters in two images simultaneously.
siameseThresholdSegmentationHeadlessBot is the corresponding function for batch processing.


Video tutorial:
Sample data:


MatBots are primitive AIs, 'assistants' if you will, that use minimalistic GUI dialogs to guide the user through a data processing pipeline in Matlab.

Isn't that an 'app'? Bots are much more restrictive than apps. Users are, to a greater extent than in an app, guided through the correct steps to perform a task. A bot usually performs a much more limited task than an app.

When possible, bots have a 'headless' mode, which allows them to execute a processing pipeline as a typical Matlab function, either on an image or a folder of images.

For more bots and tools for bio-image analysis, see

Cite As

Marcelo Cicconet (2024). ThresholdSegmentationBot (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2017a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: gh

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes