This macro for ImageJ cuts an ROI into thirds.

In June 2017, the following request was posted on the ImageJ listserv:

From: andres91
Sent: Monday, June 19, 2017 8:06 PM
Subject: Divide ROI in three equal ROI

Hello everyone. I am analyzing the color in single teeth in the complete tooth, its upper third, middle and lower. For that I have created an ROI by selecting the full contour, and then I have calculated each third manually with the selection tools, but it is a bit cumbersome. Is there a faster way, perhaps through a macro? I need to create three new selections of the same height respecting the initial contour.


I replied with this macro.

Turns out they wanted horizontal cuts and swapped the positions of the numbers in makeRectangle (x+(i*third), y, third, height); accordingly for this version.

What the horizontal version of the macro does.

Original ROI could be created by freehand drawing or automated segmentation.

Running the macro results in four ROIs being added to the ROI Manager list.