Quantifing Weka Output


I’m new to ImageJ but I have been messing around with the Weka Plugin. The classifer seems to work well for distinguishing between Red Blood Cells, White Blood Cell, Fibrin and the background using the Massons Trichrome Stain, which is exactly what we want to do.

I was wondering if there is an easy way to quantify the four colours in the output? Or can somebody suggest a way of doing this? @iarganda @ctrueden

Obviously I would then like to be able to apply the classifer to other images and quantify them too.

This is the original image

Thanks for the help,

1 Like

Hey @SeanF!!

So great that you like and can use Trainable Weka - isn’t it awesome?!!!

Just to help guide the discussion a bit. What do you mean by ‘quantify’? What exactly do you want/need to measure? The area of each cell type relative to the total field-of-view? Or positions of cell types relative to a specific feature in the image?

This will help to give some feedback… ‘quantify’ is a broad term otherwise.

eta :slight_smile:

1 Like

Hello @SeanF,

I agree with @etadobson, “quantification” can be interpreted in different ways. If you just want to know the proportion of each label (represented by a different color in the image), you can simply get the histogram (Analyze > Histogram and then List) of the label image (the “Classified image” output of the GUI).

For more ways of analyzing your result based on the label image, have a look at the label utilities in MorphoLibJ and also its measurements plugins, from which you can obtain geometric and intensity measurements of your labeled data.


Hi Etarena,

Thank you for your response.

The total area of each cell type (classifer) relative to the total field of view would be perfect. A result that gives a breakdown like below would be fantastic:
Background (Yellow) = 15%
Fibrin (Green) = 55%
Red Blood Cells = 22%
White Blood Cells (Purple) = 8%

I don’t know whether this would be easier to do on the original image or using Weka Segmentation. I am open to suggestion.

Thanks Again,

Thanks iarganda,

I will try your suggestions and report back.


1 Like

This silly macro will give you the percentage as you want if you execute it after selecting the “Classified image”:

getRawStatistics(nPixels, mean, min, max); 

setBatchMode( true );
run("Set Measurements...", "area_fraction redirect=None decimal=3");

for( i=min, n=0; i <= max; i++, n++ )
	selectWindow("Classified image");
	run("Duplicate...", "title=[to-be-thresholded]");
	setThreshold( i, i );
	run("Convert to Mask");
	setResult("Label", n, i ); 

Yes, perfect. That worked great. Thanks!

1 Like

Is there a way to modify this macro to give you the number of pixels for each class used in the segmentation instead of a percentage of the whole image?

What about taking the histogram of the output image? That will give you the number of pixels per label.