Classifying by color and shape

I would like to classify colonies by color and shape with ImageJ. Is there anybody how can tell how to do this?
The objects are round and often white, other objects are yellow.

Actually I use the “Particle analyze” but this works only with a binary picture and so I loose the color information.
Can anybody help me?
Thank you.

To classify by color, you might try thresholding by hue and saturation (user guide).

You should be able to find one setting that gives you only yellow colonies, and another that gives only the white ones.

Hope this helps.

1 Like

Hi @orguj

I’ve used jython scripting for color segmentation. Typically I first transform the image to a color space like LAB. Often times, all the objects can be found in the “intensity like” channel (lightness in LAB) . In these cases I apply thresholding and the paritcle analyzer to the “L” channel. I then perform a second step, where for each particle, I look at the mean intensity of the other channels (a and b in LAB), and classify particles based on this information. An example script and image are attached (by no means perfect, my example just shows the mechanics of performing this task, I did not optimize parameters (best threshold method, a, b, values to use for classification)).

p.s. I copied some of the code from here jython help

from ij import IJ
from ij.plugin import SubstackMaker
from ij.plugin.frame import RoiManager;
from ij.plugin.filter import ParticleAnalyzer
from ij.measure import Measurements
from java.lang import Double


# to lab color space, "RGB to CIELAB", "");

# extract L, a, and b channels
L=substackMaker.makeSubstack(imp, "1-1")
a=substackMaker.makeSubstack(imp, "2-2")
b=substackMaker.makeSubstack(imp, "3-3")

# convert to 8 bit and threshold, "8-bit", "");, "Auto Threshold", "method=Default white");

# call roi manager 
roim = RoiManager(True)
pa = ParticleAnalyzer(ParticleAnalyzer.ADD_TO_MANAGER, Measurements.AREA, None, 0, Double.POSITIVE_INFINITY, 0.0, 1.0)


# loop through ROIs
for roi in roim.getRoisAsArray():

    # take a look at mean in a and b channel

    print a_mean,b_mean

    # add particles to either class 1 or 2 based on some criteria...
    if ( (a_mean>0) & (b_mean>0)):
    elif (a_mean>0):

print "number ROIs of each class"
print len(class1)
print len(class2)
1 Like