Skip to content

Graphcut Segmentation

Back to MIB | User interface | Menu | Tools

Semi-automated image segmentation using the max-flow/min-cut graphcut method in Microscopy Image Browser (MIB).


Overview

The Graphcut segmentation tool in MIB provides semi-automated segmentation using the max-flow/min-cut algorithm. It is based on the Max-flow/min-cut algorithm by Yuri Boykov and Vladimir Kolmogorov, with a MATLAB implementation by Michael Rubinstein.

Graphcut segmentation interface

Instead of segmenting individual pixels, it operates on superpixels (2D) or supervoxels (3D), generated via the SLIC algorithm by Radhakrishna Achanta et al. or the Watershed algorithm. SLIC superpixels excel for objects with intensity contrast, while Watershed superpixels are better for objects with distinct boundaries.
Precomputing superpixels requires initial processing time but accelerates subsequent segmentation.


General example

A demonstration is available in this video:
Watch on YouTube

How to use

Graphcut workflow example

Steps to perform graphcut segmentation:

  1. Use two labels to mark background and object areas of interest
  2. Launch the tool via Menu → Tools → Semi-automatic segmentation → Graphcut
  3. Choose a mode: 2D or 3D
  4. Select superpixel/supervoxel type: SLIC or Watershed
  5. Generate superpixels/supervoxels by clicking Superpixels/Graph
  6. Verify and adjust superpixel size if necessary
  7. Click Segment to start segmentation
Note

Some functions may require compilation; see the System Requirements page for details


Mode panel

The Mode panel lets you select the segmentation scope.

Mode panel options

  • segments only the current slice in the Image View panel
  • applies 2D segmentation to each slice individually
  • performs 3D segmentation on the entire dataset or a subarea (see Subarea panel below)
  • segments a large dataset by dividing it into subvolumes (defined by Chop fields). the subvolume centered in the Image View panel is processed (enable the center marker via on the toolbar).
    Use Segment All to process all subvolumes

Subarea panel

The Subarea panel defines a dataset subset for processing, useful for large datasets or binning.

Subarea panel settings

  • X:... sets the width range (e.g., 1:512)
  • Y:... sets the height range
  • Z:... sets the z-slice range
  • from Selection fills X, Y, and Z with coordinates from the Selection layer’s bounding box
  • Current View limits X and Y to the visible area in the Image View panel
  • Reset restores full dataset dimensions
  • Bin x times... applies a binning factor to reduce detail for faster processing

Warning

Auto update mode () is unavailable with binned datasets


Calculation of superpixels/supervoxels

Superpixels (2D) or supervoxels (3D) are precomputed using SLIC or Watershed algorithms. SLIC suits intensity-contrast objects (e.g., lipid droplets), while Watershed excels for boundary-defined objects.

Image example of clusters

SLIC vs. Watershed superpixels

Superpixel settings

  • Superpixels selects the type: SLIC or Watershed
  • Size of superpixels sets approximate superpixel size (SLIC only)
  • Reduce number of superpixels scaling factor defining size of superpixels (Watershed only)
  • Compactness (1-99) controls superpixel squareness; higher values yield squarer shapes (SLIC only)
  • Color channel chooses the color channel for superpixel calculation
  • Type of signal selects black-on-white (electron microscopy) or light-on-black (light microscopy)
  • Chop... defines subvolume sizes for 3D volume grid mode or SLIC supervoxels
  • saves the graphcut structure and supervoxels to disk automatically
  • enables parallel processing for Watershed clustering in 3D volume grid mode, boosting performance
  • uses supervoxel indices for final models, improving performance but requiring more memory
  • Superpixels/Graph generates superpixels and organizes them into a graph
  • Import loads superpixels and graphs from disk or MATLAB
  • Export saves superpixels and graphs to a file, MATLAB, a new model, or as a Lines3D graph object (not recommended for many superpixels; see this video)
  • Preview superpixels displays the generated superpixels

Image segmentation settings

The Graphcut workflow uses labeled areas (Background and Object) for segmentation, offering faster interaction than the Watershed workflow. It handles objects with both boundaries and intensity contrast, making it versatile.

Segmentation settings

  • Background selects the model material labeling background areas
  • Object selects the model material labeling objects
  • Update lists refreshes material lists
  • updates segmentation automatically when materials change (best for small datasets, ~400x400x400 pixels)

Warning

In Auto update mode, use only the A shortcut (not Shift+A).
Recalculate final segmentation with Segment.
This mode is unavailable with binned datasets


Image segmentation example

Follow these steps to segment mitochondria using Graphcut:

  • Load a sample dataset: Menu → File → Import image from → URL, enter http://mib.helsinki.fi/tutorials/WatershedDemo/watershed_demo1.tif
  • Add a material named Background in the Segmentation panel with + (right-click to rename)
  • Use the Brush tool to label cytoplasm, then press A to add it to Background
Snapshot

Labeling Background

  • Add another material named Seeds with +
  • Label mitochondria interiors, then press A to add to Seeds
Snapshot

Labeling Seeds

  • Start Graphcut via Menu → Tools → Semi-automatic segmentation → Graphcut
  • Select Watershed in Superpixels
  • Ensure Background and Seeds are set in Image segmentation settings
  • Click Segment to segment mitochondria
  • Add more seeds to refine, then re-segment with Segment or enable
  • Results appear in the Mask layer
  • Optionally smooth the mask: Menu → Mask → Smooth Mask
Snapshot

Segmented mitochondria


References


Back to MIB | User interface | Menu | Tools