Updated by Dave Mason 2018-07-02 View revision File shiftLine.ijm Modified Side-by-side diff More Ignore whitespace Hide word diff //-- Draw the new line and show both makeSelection("freeline", xpos, ypos_new); roiManager("add"); -roiManager("Show All"); +roiManager("Show All"); + +//-- Extra code to turn this into an area selection + +//-- Combine the two lines into a single set of X and Y coordinates +xpos_area=Array.concat(xpos,Array.reverse(xpos)); +ypos_area=Array.concat(ypos,Array.reverse(ypos_new)); + +//-- Draw the area shape and add to ROI manager +makeSelection("freehand", xpos_area, ypos_area); +roiManager("add");
Created by Dave Mason 2018-07-02 View revision File shiftLine.ijm Added Side-by-side diff More Ignore whitespace Hide word diff +//-- 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");