Segmentation newbie help


I have a series of images that show aquaculture netting against a uniform background. The netting accumulates darker fouling (i.e. slime!) over time. I’m looking to find a semi-automated or automated way to segregrate netting from background. The images have been taken with reasonable but not perfect lighting control, and so there are slight variations in background brightness across images and also between images. There are so many options on how we might handle this in ImageJ - the auto threshold methods, the standard segmentation plugins, and presumably a number of other plugins available from 3rd party update sites. I’m hoping someone with more experience can give me some tips on which methods to explore. The goal is take an image like the one below and segment into two categories (classes?) of pixels - foreground (the netting and fouling combined) and background (the real world background).

Pointers appreciated.


Hi @rustyconc -

Welcome to the Forum!

To get you started with ImageJ and Segmentation … Here are some super helpful links that are worth going through:

I suppose I would give a try with TWS… I ran it on a cropped section of your image - it wasn’t perfect, but could be improved if you put in the time/effort:

I’m not sure I used the best selection of training features in your case - Gaussian blur, Sobel filter, Minimum, Kuwahara. I’m sure there are alternative/better combinations that you can try.

Hope this at least gets you started though!

eta :slight_smile:


To add to @etadobson’s suggestions, you can also do some color thresholding in Lab space:


Good day Russel,

in my opinion you’ve done a good job with image acquisition, except, as you mentioned, the background uniformity. It can be improved post hoc by applying
“Process >> Subtract Background”. Just try various parameters.

Here is what I get from running the following macro:

run("Subtract Background...", "rolling=100 light sliding disable");
setOption("BlackBackground", true);
run("Convert to Mask");

Paste the code to an empty macro window (Plugins >> New >> Macro) and run it.

You get the areas by measuring the binary image and its inverse.



1 Like


what I found simple and “robust” on color image, is to go the HSB color space

title = getTitle();

// Convert to HSB color space
run("Duplicate...", "title=HSB ");
run("HSB Stack");

// the 2nd channel , aka Saturation has "less"  jpg artifact 
run("Duplicate...", "title=Saturation ");

// apply some blur (if you wanz to smooth things a little)
run("Gaussian Blur...", "sigma=2");

// Make Binary using threshold
// you can try other algorythm  by just changing name
setAutoThreshold("Triangle dark");
setOption("BlackBackground", true);
run("Convert to Mask");

//run("Invert"); // depending what you want to select
run("Create Selection");

//restore the selection to the original image
run("Restore Selection");



1 Like

Thank you all for the ideas - we have some exploration to do now!

1 Like

Addendum: this thread is also relevant.