As a starting point, there are tutorials here:
And a list of the available macro functions is here:
On the macro function page, you’ll find a lot of example macros that show you how the functions can be used in practice.
I would read the tutorials so you can start to understand how functions and variables work in the macro language.
For a start, when you have this line in your macro:
you are saying: find out the position of the active ROI in the image, and store its x coordinates in an array called
xpoints and its y coordinates in an array called
The elements of the array are specified with brackets.
xpoints is the first element, and therefore is the x coordinate of the first point in your multipoint selection.
Now to make the line.
makeLine(x1, y1, x2, y2)
makes a line between point (x1, y1) and point (x2, y2).
So to make these commands work together, you substitute the coordinates you collected in the array:
Here is a working macro (tested in Fiji) that shows the commands in action:
// ImageJ macro demonstrating how to retrieve points from a multi-point selection
// and make a line between them
// For demonstration -- delete the code between the **** later
// open a sample image
run("AuPbSn 40 (56K)");
// make an example selection
xpoints = newArray(40, 440);
ypoints = newArray(50, 270);
makeSelection("point", xpoints, ypoints);
// Keep the code below to get and use the coordinates from YOUR multipoint selection.
// First make your selection, then run the macro.
Roi.getCoordinates(xpoints, ypoints); // store point coordinates
makeLine(xpoints,ypoints,xpoints,ypoints); // make line
run("Measure"); // measure the line
I highly recommend working through the tutorials referenced above, if this is still confusing!