Skip to content

Instantly share code, notes, and snippets.

@lacan
Last active March 29, 2019 01:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lacan/74f550a21ea97f46c74f1a110583586d to your computer and use it in GitHub Desktop.
Save lacan/74f550a21ea97f46c74f1a110583586d to your computer and use it in GitHub Desktop.
Points To Curve Distance using Distance Map imageJ Macro #ImageJ #Macro #Fiji
/*
* Distance of points to freehand line
* using distance transform
* Inspired by work from 2011 For Dr. Giuseppe Lo Sasso
*
* Olivier BURRI November 2016
* Provided as an example for a post on the ImageJ Forum
* http://forum.imagej.net/t/quantifying-distance-of-multiple-points-from-a-freehand-line/3287
*/
name = getTitle();
roiManager("Show All");
roiManager("Reset");
run("Clear Results");
// 1. Draw Curve
setTool("freeline");
waitForUser("Draw your freehand curve and click OK");
run("Fit Spline");
Roi.setName("Curve");
roiManager("Add");
// 2. Draw Points
setTool("multipoint");
waitForUser("Draw your points and click OK");
Roi.setName("Points");
roiManager("Add");
// 3. Make Distance Map
getDimensions(x,y,c,z,t);
newImage(name+" - Distance Map", "8-bit white", x, y, 1);
setForegroundColor(0, 0, 0);
roiManager("Select",0);
run("Draw", "slice");
setAutoThreshold("Default dark");
run("Convert to Mask");
run("Exact Euclidean Distance Transform (3D)");
// 4. Measure Points
roiManager("Select", 1);
run("Measure");
// Result appears in "Mean Column
@Amanda-McLaughlin
Copy link

do you have any information about the "Exact Euclidean Distance Transform (3D)" plugin? I'm not seeing any online and would love to read more about it.
thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment