What is the best way to learn how to mimic something from the UI using the Java API

I have a 8-bit monochrome image and I want to make it a color (‘green’ for example). In the UI I can select Image -> Lookup Tables -> Green, which colorizes the image. Then when I ‘save as’ a png file, the image is still 8-bit but now in the green channel.

I want to mimic this (and potentially other) behavior in an image processing project I am working on, but I am having trouble figuring out what APIs are being used in the UI implementation.

Thanks in advance for any advice for my specific issue or how to generally figure out how the UI is using the API in its features.


Hi @ericmandm,

Welcome to the forum.

If I understand you correctly, you can use the macro recorder Plugins > Macros > Record....

As you interact with the UI, code will appear in the Recorder window. You can pick the language you’d like:

  • Macro
  • Python
  • Javascript
  • Beanshell (use this one if you want to translate the code into Java)



Hi John,
I recorded the actions in the UI and got this:
run(“Split Channels”);

However, this was not very enlightening for me about how to duplicate this functionality in a Java class using the ij API. Do you have any other advice for me?


It looks like you recorded into the macro language, not Beanshell.

The code you get from beanshell is almost exactly Java code. Just:

  1. Add import statements
  2. declare variable types.

Give it a try, and post back if you run into errors,