Search code examples
javaapipluginsimage-processingimagej

ImageJ: Execute commands with run() in JAVA


I executed this "Enhance Contrast..." command (in ImageJ: Process > Enhance Contrast...) with the following JAVA code:

IJ.run(imagePlus, "Enhance Contrast...", "");

But, I don't know how to execute some other commands e. g.: Process > Binary > Make Binary.

Finally, I would like to launch the plugin: Anisotropic Diffusion 2D. After dropping it to ImageJ it will be shown in: Plugins > Anisotropic Diffusion 2D.

How can I execute both commands in my JAVA-code?


Solution

  • A useful tool for answering these questions is ImageJ's macro recorder. Open up Plugins > Macros > Record ... and change the "Record" option to Plugin. If you then try to run the menu option for "Make Binary", you will see the following in the macro recorder:

    IJ.run(imp, "Make Binary", "");
    

    You can do the same for "Anisotropic Diffusion 2D".