Created by
Dave Mason
| //-- CLose existing images
close("*");
//-- open a sample image
run("Blobs (25K)");
//-- Threshold and create particles
setThreshold(125, 248);
run("Analyze Particles...", "show=Nothing exclude clear record");
//-- For each object, calculate the Feret parameters and draw the line
for (i=0; i<nResults; i++) {
x = getResult('XStart', i);
y = getResult('YStart', i);
doWand(x,y);
drawFeretsDiameter();
if (i%5==0) {showProgress(i/nResults);}
run("Select None");
resetThreshold;
}
function drawFeretsDiameter() {
//-- FeretDiameter macro example
requires("1.29n");
run("Line Width...", "line=1");
diameter = 0.0;
getSelectionCoordinates(xCoordinates, yCoordinates);
n = xCoordinates.length;
for (i=0; i<n; i++) {
for (j=i; j<n; j++) {
dx = xCoordinates[i] - xCoordinates[j];
dy = yCoordinates[i] - yCoordinates[j];
d = sqrt(dx*dx + dy*dy);
if (d>diameter) {
diameter = d;
i1 = i;
i2 = j;
}
}
}
//-- Create a line selection
makeLine(xCoordinates[i1], yCoordinates[i1],xCoordinates[i2],yCoordinates[i2]);
//-- Pull the intensity profile alone the line
profile = getProfile();
//-- Print the profile intensities to the log
Array.print(profile);
//-- Draw the line in a non-destructive overlay
Overlay.addSelection("magenta");
}
|