Drawing a best fit line over an image based on a set of X Y coordinates in a table

Hi there,

I have a list of X Y coordinates in a .csv file and would like to draw a line connecting these coordinates into a an overlayed line. I think that this macro is close, but struggling a bit:

for (i=0; i<nResults; i++) {
frame = getResult(“f”, i);
x = getResult(“x”, i);
y = getResult(“y”, i);
drawline(x-1, y-1) (x-2, y2);
The Results are in three columns (f,x,y). Any help would be greatly appreciated. Thanks!

Hi @shnmchlgrffn,

First, you have to ensure that your point are well sorted (I mean that point #2 has to be linked with point #1 and point #3…)
Then, to draw a line, you need 2 points

for (i=1; i<nResults(); i++)
   frame = getResult(“f”, i);
   x1 = getResult(“x”, i-1);
   y1 = getResult(“y”, i-1);
   x2 = getResult(“x”, i);
   y2 = getResult(“y”, i);

   drawline(x1, y1, x2, y2);


Thank you! This works perfectly! You are really helping me learn this stuff and appreciate your assistance greatly.