How to process results of a measurement in imageJ using scripting

Suppose I made a measurement such as below:

Then I want to further process this measurement, for example subtract two columns or divide two columns. I want to use python such as below:

To access the results I used getResults(“Mean(bl)”,1). But I get an error that this function is not recognized. Importing imageJ by import ij did not help.

How can I access the measurement results by scripting using Python?

From any scripting language other than IJ1 macros, you’ll have to use ImageJ’s Java API to interact with the application. See for an overview of Java API documentation pages by project.

In your case, you might want to query an ImageJ1 ResultsTable object for the values in the results table. Looking through the available methods, getValue() might fit your needs.

In Python/Jython (and using a script parameter to get the ResultsTable object), this will look like:

#@ ResultsTable rt

print rt.getValue("Mean(bl)", 1)

And because it’s the Java API, it looks almost the same in other scripting languages, e.g. Groovy:

#@ ResultsTable rt

println rt.getValue("Mean(bl)", 1)

NB: You can also find the equivalent API call for a given macro function by looking at the source code of

Towards the end of that method, you’ll see that rt.getValueAsDouble is called after getting the correct column index with rt.getColumnIndex(column).

It’s not trivial to spot however, I’m afraid…