Scripting in ImageJ

I am attempting to measure the thickness of photomultiplier tube glass using ImageJ, and I want to script it in Python to automate the process.

To do this manually, I use the line segment tool to draw a horizontal line through the center of the image (as shown in the picture), then do a radial reslice. I draw line segments through different parts of the image in each slice, and export the plot profile data as a csv file. Is there a way to script this in Python?

Apart from the Python-question (btw the ImageJ-macro language is really easy), did you consider using the “Polar Transformer”-plugin?

See this Forum-thread.

Hi,

before diving deep: do you mean Fiji jython/python? So a python script written in the script editor of Fiji?
The “normal” cpython is a bit of a different world.

For getting started on jython/python you can find tutorials here:
Python Tutorial by Albert Cardona
Fiji page on python
and some more examples by Albert Cardona

For finding the specific plugin functions I recommend to use the recorder (Plugins>Macro>Record...) while executing the steps, language prefereably set to to Java. If nothing useful gets recorded, then to Macro.

Several core classes also have an API page, here for example for the quite useful IJ package with utility functions: IJ (ImageJ API)

Edit: Also consider the macro language. It has less functionality than python but the experience is much smoother (autocomplete, proper recording, documentation). And for many not too complex tasks it’s enough.

2 Likes