Skip to content

ImageJ

It's the only reason I ever typed Java code at all.

Easy install

Run these commands to install ImageJ/FIJI and install a shortcut.

# Get the software.
mkdir -p ~/Software/Fiji/
curl https://downloads.imagej.net/fiji/latest/fiji-linux64.zip -o ~/Software/Fiji/fiji-linux64.zip
unzip ~/Software/Fiji/fiji-linux64.zip  ~/Software/Fiji/

# Get the desktop file.
mkdir -p ~/.local/share/applications/
curl https://la.nada.ar/notes/uploads/ImageJ2.desktop -o ~/.local/share/applications/ImageJ2.desktop
sed -i "s|/home/username|$HOME|g" ~/.local/share/applications/ImageJ2.desktop

# Done!

Add a button

From the docs: https://imagej.net/ij/developer/macro/macros.html#tools

  1. Open the "Startup macros".
  2. Add your macro. It's name/title can't contain hyphens "-", and must end with the "Tool" keyword (see docs, and the example below).
  3. Additionally, a macro ending in Action Tool will run when clicked (instead of becoming enabled and waiting for a click on an image).
  4. To add an icon, place a 26x26 png file in the macros/toolsets/icons/ directory in ImageJ's main folder.
  5. Restart ImageJ.

Example "Scale to Fit" button:

// Scale-to-fit shortcut button
macro "Scale to Fit Action Tool - icon:scaletofit.png" {
       run("Scale to Fit");
    }

Example icon:

scaletofit

Tip

You may need to click on "Restore Startup Tools" for the new tool to appear.

alt text

Add shortcuts

  1. Open the "Startup macros".
  2. Add your macro shortcuts.

Example "Select Counter" shortcuts, bound to numbers 1, 2, and 3 on the keyboard:

// Point tool shortcuts: https://forum.image.sc/t/macro-to-set-shortcut-for-multi-point-counter-type/3797/2
macro "Type 1 [1]" {run("Point Tool...", "counter=1");}
macro "Type 2 [2]" {run("Point Tool...", "counter=2");}  
macro "Type 3 [3]" {run("Point Tool...", "counter=3");}