Snippets

Dave Mason Pulls Centroid from Oval selections and draws on as overlay (https://forum.image.sc/t/center-of-oval-selections/23315)

Created by Dave Mason last modified
//-- Open an example image
run("Blobs (25K)");
getPixelSize(unit, pixelWidth, pixelHeight);

//-- Select the oval tool
setTool("oval");

//-- Prompt the user to draw an oval
waitForUser("Draw an oval");
List.setMeasurements;
x1 = List.getValue("X");
y1 = List.getValue("Y");
Overlay.addSelection("green", 2);
run("Select None");

//-- Prompt the user to draw an oval
waitForUser("Draw an oval");
List.setMeasurements;
x2 = List.getValue("X");
y2 = List.getValue("Y");
Overlay.addSelection("green", 2);
run("Select None");

//-- Draw the line as an overlay
makeLine(x1/pixelWidth, y1/pixelWidth, x2/pixelWidth, y2/pixelWidth);
Overlay.addSelection("magenta", 3);
run("Select None");

Comments (0)

HTTPS SSH

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