Segmentation



Learn
Topics
Introduction
Getting Started
User Guides
Tutorials
Tips and Tricks
Presentations
Plugins
Techniques
All Techniques
Colocalization
Deconvolution
Registration
Segmentation
Stitching
Tracking
Visualization
Scripting
Overview
Parameters
Basics of script writing
Batch processing
Script Editor
Auto Imports
Templates
Running headlessly
Comparisons
Toolbox
Multithreading in Clojure
Multithreading in JavaScript
Chess in Jython
Languages
BeanShell
Groovy
ImageJ Macro
JavaScript
Lisp (Clojure)
MATLAB
Python (Jython)
R (Renjin)
Ruby (JRuby)
Scala



Tip: See this helpful workshop on Image Segmentation for another great overview of Segmentation!


Introduction

Image segmentation is "the process of partitioning a digital image into multiple segments." (Wikipedia)

Segmentation-overlay.jpg Segmentation-boundaries.jpg

It is typically used to locate objects and boundaries.

More precisely, image segmentation is the process of assigning a label to every pixel in an image such that pixels with the same label share certain visual characteristics.

Easy workflow

One plugin which is designed to be very powerful, yet easy to use for non-experts in image processing:

Plugin Name Short Description Highlights Plugin Snapshot
Trainable Weka Segmentation A tool that combines a collection of machine learning algorithms with a set of selected image features to produce pixel-based segmentations.
  • Can be trained to learn from the user input and perform later the same task in unknown (test) data
  • Makes use of all the powerful tools and classifiers from the latest version of Weka
  • Provides a labeled result based on the training of a chosen classifier
  • Ease of use due to its graphical user interfaces
TWS-GUI-after-training.png

Give it a try—you might like it!

Flexible workflow

One good workflow for segmentation in ImageJ is as follows:

  1. Preprocess the given images
  2. Apply an Auto Threshold
  3. Create and manipulate a mask
  4. Create and transfer a selection from a mask to your original image
  5. Analyze the resulting data

Preprocessing

Preprocess the image using filters, to make later thresholding more effective. Which filter(s) to use is highly dependent on your data, but some commonly useful filters include:

Adjusting Threshold

Tree ring sample image with a threshold applied for a B&W image

Ideally you want to use one of the auto-threshold methods, rather than manually tweaking, so that your result is reproducible later on the same data, and on multiple other datasets.

  • Open your image
  • Select Image  ▶ Adjust  ▶ Threshold...
  • Specify whether or not the background should be dark or light
  • Adjust the minimum and maximum sliders until you are satisfied with the saturation level of your image

Creating Masks

Over-saturated mask is eroded around the center tree ring
  • Select Edit  ▶ Selection  ▶ Create Mask
  • Based on the image and set threshold, some portions of the image may be over/under saturated
    • Select the portion of the image that needs to be adjusted
    • Select Dilate to grow the included pixels to further saturate this portion of the image or Erode to remove saturation
  • One quick way to split overlapping objects is the Watershed command.

Selections

Selections on the mask

Creating Selections

  • Select Edit  ▶ Selection  ▶ Create Selection to select the objects within the mask
  • To deselect a portion of the image, select Shift+click
Selections on the reverted image

Transferring Selections

  • Before transferring the mask's selections, revert the image to its original form by selecting Shift+E
  • Select first the mask, then the original image, and select Shift+E to transfer the mask's selections

Analysis

Do some numerical analysis on the selected data:

  • Measure the entire selection directly.
  • Use Analyze Particles to extract desirable objects from your selection and report individual statistics on them.
  • Use the ROI Manager to Add the selection and then Split it (under the More button), then use Multi Measure (also under More) to report statistics on the objects.
  • Write a macro to automate this sort of analysis, loop over objects in the ROI manager, measure and manipulate them, etc.

See also