edsimmons wrote
Hi ImageJ world,
<snip>
Please could someone suggest a simple method of measuring the distance in pixels between the two point selections, one result per slice? I'm not quite sure how best to access the locations of the selections.
I have tried a number of methods based on macros found on the mailing list but I'm not quite getting it right.
Any help greatly appreciated, thanks in advance!
Ed
Hi everyone,
I've sorted a solution that works for my needs, the macro is as follows:
function length (x1, y1, x2, y2) {
sum_difference_squared = pow((x2 - x1),2) + pow((y2 - y1),2);
output = pow(sum_difference_squared, 0.5);
return output;
}
run("Duplicate...", "title=-1 duplicate");
run("Gaussian Blur...", "sigma=2 stack");
run("Clear Results");
for(i=0;i<nSlices();i++){
setSlice(i+1);
run("Find Maxima...", "noise=45 output=[Point Selection] exclude light");
run("ROI Manager...");
roiManager("Add");
}
roiManager("Deselect");
run("Set Measurements...", " centroid display redirect=None decimal=3");
roiManager("Measure");
r=nResults();
X=newArray(r);
Y=newArray(r);
X2=newArray(r);
Y2=newArray(r);
for(i=0;i<r-1;i++) {
if(getResult("Slice",i) == getResult("Slice",i+1)){
X[i]=getResult("X",i);
Y[i]=getResult("Y",i);
X2[i]=getResult("X",i+1);
Y2[i]=getResult("Y",i+1);
distance = length(X[i],Y[i],X2[i],Y2[i]);
setResult("Distance",i,distance);
}
}
I hope this is of some use to someone.
Ed