Measuring tool with segmented line

Dear all,

I have written a macro to measure seals from pictures taken from a drone and obtain some measurements. The macro uses the strait line tool at the beginning and based on this line a series of perpendicular lines at regular intervals along the line itself are generated and used to obtain further measurements. I would liketo do the same thing with the segmented line tool so that I can obtain the total length of the segmented line and associated perpendicular crossing lines (see Figure 4 at ). I can,t figure out how to do it. Furthermore, in the macro I am using the multipoint tool. I would like to specify that 20 points must be selected and if there are less than 20, say 17, my result table will still have 20 rows with 3 NA for the missing points. At the same time, if more than 20 are selected, I would like a warning message to show saying that more than 20 points have been selected and that the extra ones will not be measured and therefore included in the result table. Here too, I have no idea how to do it (, sorryI am a marine biologist and not a programmer…). Any help is greatly appreciated.

N

Here is my macro:

macro "seal measuring tool[J]" {
run("ROI Manager...");
roiManager("Show All");

waitForUser("Select Strait Line Tool and highlight the Total Body Length");

getLine(x0,y0,x11,y11,width);
dx = x11 -x0;
dy = y11 -y0;
xstep = dx/11;
ystep = dy/11;

// Interpolate segment points
xs=x0 - 1*xstep
x1 = x0 + 1*xstep;
x2 = x0 + 2*xstep;
x3 = x0 + 3*xstep;
x4 = x0 + 4*xstep;
x5 = x0 + 5*xstep;
x6 = x0 + 6*xstep;
x7 = x0 + 7*xstep;
x8 = x0 + 8*xstep;
x9 = x0 + 9*xstep;
x10 = x0 + 10*xstep;
x11 = x0 + 11*xstep;
x12 = x0 + 12*xstep;
x13 = x0 + 13*xstep
ys=y0 - 1*ystep
y1 = y0 + 1*ystep;
y2 = y0 + 2*ystep;
y3 = y0 + 3*ystep;
y4 = y0 + 4*ystep;
y5 = y0 + 5*ystep;
y6 = y0 + 6*ystep;
y7 = y0 + 7*ystep;
y8 = y0 + 8*ystep;
y9 = y0 + 9*ystep;
y10 = y0 + 10*ystep;
y11 = y0 + 11*ystep;
y12 = y0 + 12*ystep;
y13 = y0 + 13*ystep;

// Create sections at regular intervals along the highlited Total Body Length of the seal

makeLine(xs, ys, x1, y1);
	Roi.setStrokeColor(255,126,0);
	run("Rotate...", "angle=90"); 
	roiManager("Add");
	
makeLine(xs, ys, x3, y3);
	Roi.setStrokeColor(255,126,0);
	run("Rotate...", "angle=90"); 
	roiManager("Add"); 

makeLine(x0, y0, x4, y4);
	Roi.setStrokeColor(255,126,0);
	run("Rotate...", "angle=90"); 
	roiManager("Add"); 

makeLine(x1, y1, x5, y5);
	Roi.setStrokeColor(255,126,0);
	run("Rotate...", "angle=90"); 
 	roiManager("Add"); 

makeLine(x2, y2, x6, y6);
	Roi.setStrokeColor(255,126,0);
	run("Rotate...", "angle=90"); 
 	roiManager("Add"); 

makeLine(x3, y3, x7, y7);
	Roi.setStrokeColor(255,126,0);
	run("Rotate...", "angle=90"); 
 	roiManager("Add"); 

makeLine(x4, y4, x8, y8);
	Roi.setStrokeColor(255,126,0);
	run("Rotate...", "angle=90"); 
 	roiManager("Add"); 

makeLine(x5, y5, x9, y9);
	Roi.setStrokeColor(255,126,0);
	run("Rotate...", "angle=90"); 
 	roiManager("Add"); 

makeLine(x6, y6, x10, y10);
	Roi.setStrokeColor(255,126,0);
	run("Rotate...", "angle=90"); 
 	roiManager("Add"); 

makeLine(x7, y7, x11, y11);
	Roi.setStrokeColor(255,126,0);
	run("Rotate...", "angle=90"); 
 	roiManager("Add"); 

makeLine(x8, y8, x12, y12);
	Roi.setStrokeColor(255,126,0);
	run("Rotate...", "angle=90"); 
 	roiManager("Add"); 

makeLine(x10, y10, x12, y12);
	Roi.setStrokeColor(255,126,0);
	run("Rotate...", "angle=90"); 
	roiManager("Add"); 

makeLine(x0, y0, x11, y11);
	Roi.setStrokeColor(255,126,0);
	roiManager("Add"); 
	run("Measure");

setTool("multipoint");
	waitForUser("Select points");
	Roi.setStrokeColor(0,255,0);
	roiManager("Add");
	run("Measure");

setTool("line");
	waitForUser("Select Standard Body Length");
	getLine(x100,y100,x101,y101,width);
	run("Measure");

setTool("line");
	waitForUser("Select Axillary Width");
	getLine(x102,y102,x103,y103,width);
	makeLine(x102,y102,x103,y103);
	Roi.setStrokeColor(0,72,186);
	roiManager("Add");
	run("Measure");

setTool("line");
	waitForUser("Select Umbelical Width");
	getLine(x104,y104,x105,y105,width);
	makeLine(x104,y104,x105,y105);
	Roi.setStrokeColor(0,72,186);
	roiManager("Add");
	run("Measure");

runMacro("photosave"); 
run("Clear Results");
roiManager("Deselect");
roiManager("Delete");

close();

}