Snippets

Dave Mason Make a duplicate offset line [http://forum.imagej.net/t/how-to-draw-a-curved-line-in-imagej-and-move-it-for-certain-pixels-can-i-also-make-a-selection-of-the-area-in-between-the-two-lines/11793]

You are viewing an old version of this snippet. View the current version.
Revised by Dave Mason 8a46e43
//-- Make a demo image
roiManager("reset");
newImage("MoveLine", "8-bit black", 512, 512, 1);

//-- select the tool and wait for the user to draw a line
setTool("freeline");
waitForUser("Draw a line");
roiManager("add");

//-- convert the freehand into discreet points and pull the coordinates
run("Fit Spline");
getSelectionCoordinates(xpos,ypos);

//-- Shift the line down by 50 pixels
ypos_new=newArray(ypos.length);
for (points=0;points<ypos.length;points++){
	ypos_new[points]=ypos[points]+50;
}

//-- Draw the new line and show both
makeSelection("freeline", xpos, ypos_new);
roiManager("add");
roiManager("Show All");
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.