This is an ImageJ plugin (with a GUI) that allows users to select a square ROI with specified coordinates. More importantly, this is a template of a (really) minimal ImageJ plugin.
Below is a step-by-step instruction to make a functional plugin without the tedium of configuring an IDE - a text editor will do the job as long as you know how to code in java [to learn the source codes of ImageJ utilities, use Plugins
> Utilities
> Find Commands...
> (choose a specific command) > Source
]. Note that these steps are for Unix-like OS's (macOS/Linux distributions/...); use Command Prompt/PowerShell on Windows.
-
Download this repository entirely and edit the source code (
SelectSquareROI.java
) and the configuration file (plugins.config
- do not change this filename) accordingly. -
Prepare dependency package(s) (here
ij.jar
is needed, which could be downloaded from here) in the same folder as our source code. -
Install JDK. On Windows, add the folder containing all executables to the
PATH
environment variable; otherwise, you need to provide the full path of the executable (if the path contains special characters, you may find this helpful). -
Go to Terminal and compile our source code into a java class file:
javac -classpath ij.jar SelectSquareROI.java
(Note: edit the filename accordingly). If you want to check the version of a java class file and determine its compatibility, you might find this thread helpful. -
Compress the configuration file and the compiled java class file into one java archive file (
Select_Square_ROI.jar
):jar -cfe Select_Square_ROI.jar SelectSquareROI SelectSquareROI.class plugins.config
(Note: edit the filenames and the class name(s) accordingly; include an underscore in the filename of the java archive file). -
Move our java archive file into the
plugins
subfolder of ImageJ (or open ImageJ and run "Plugins
>Install Plugin...
"). -
Restart ImageJ and test the plugin. There should now be a corresponding option in the menu if the configuration file is written correctly.
-
(Optional) set a shortcut for our plugin by running the ImageJ command: "
Plugins
>Shortcuts
>Add Shortcut...
".