The Built-in Macro Functions page is the best place to look for such things… having that open while you are editing code is super helpful…
But you are correct - in that if you Measure the centroids of your selections - you can use macro code to extract those values from the Results Table. This is the code call I would use for just that (as found in the Built-in Macro Functions page I linked above):
Returns a measurement from the ImageJ results table or NaN if the specified column is not found. The first argument specifies a column in the table. It must be a “Results” window column label, such as “Area”, “Mean” or “Circ.”. The second argument specifies the row, where 0<= row <nResults. nResults is a predefined variable that contains the current measurement count. (Actually, it’s a built-in function with the “()” optional.) Omit the second argument and the row defaults to nResults-1 (the last row in the results table). See also: nResults, setResult, isNaN, getResultLabel.
So the code call would look like:
getResult("X", i); or
getResult("Y",i); and most likely you’d need to use a
for loop to move through the rows…
If you have more specific questions regarding code snippets… just share them with us here and we can help.