Quickly Make Dotted Lines from a Set of ROIs


I’m looking for a macro or script that applies the Dotted Line plugin to each ROI loaded into the ROI Manager.

You’ll have to install the Dotted Line plugin on your ImageJ distribution. I am using ImageJ Fiji 1.52p; more info on my version: ImageJ-OP-version|400x284

This is the (32-bit) image: POP2-1.tif (40.8 KB)

This is the set of ROIs for the image: ROIs 1.zip (6.0 KB)

Right now I can get part of the desired result by doing the following:

-load the ROIs into the ROI manager
-manually select the first ROI
-run Dotted Line plugin
-manually select next ROI
-run Dotted Line plugin

Here is a recorded macro that outlines the above procedure: dotted_manual.ijm (192 Bytes). It gives me an image like this: POP2-1-dotted.tif (29.5 KB). Note the Dotted Line plugin converts the 32-bit image into RGB; it is okay.

Is there a way to loop through loaded ROIs and apply the Dotted Line plugin on each loop? I’m completely unfamiliar with ImageJ language syntax, and thought this would be an easy problem for more experienced users.

Thanks in advance,

count = roiManager("count")
for (i=0; i<count; i++){
   roiManager("select", i);
   run("Dotted Line", "line=1 dash=3,3");

I came up with this moments before you posted, but will mark your answer as the solution. Thank you!

1 Like