What’s the recommended way of finding out how I can reproduce the same functionality of a specific ImageJ menu item in my java code? I am developing a java application that uses ImageJ’s functionality behind the scene, but the UI of ImageJ is not supposed to be visible. I am using the following line of code to have access to the ImageJ’s context if needed:
final ImageJ ij = new ImageJ();
So, suppose that I want to have the funcionality of “Image > Type > 8-bit” applied to an
ImagePlus object I have in my code. The first approach that I can think of is to use the “Command Finder”:
It suggests that the 8-bit command resides in
ij.plugin.Converter("8-bit") class. But how can I use this piece of code in my application? Googling “ij.plugin.Converter” gets me to the “Converter” class document, which suggests that the
Converter is a plugin and I can use it by calling its
run method. But I cannot call the
run method because I am not developing a plugin.
There is however a piece of code in stackoverflow, which shows how this can be done using the
import ij.ImagePlus; import ij.process.ImageConverter; // ... ImagePlus imp = IJ.getImage(); ImageConverter ic = new ImageConverter(imp); ic.convertToGray8(); imp.updateAndDraw();
Fortunately somebody has already demonstrated how to convert an
ImagePlus object to 8-bit using the
ij.process.ImageConverter class. But what about other functionalities? Is there any document out there which indicates what class can be used for each menu item?