Login  Register

Measuring between point selections in a stack

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Measuring between point selections in a stack

edsimmons
Hi ImageJ world,

Please could someone point me in the right direction?

I have acquired a stack of images with progressively higher magnification at each level. Each image is a white background with two dots.
Using a macro I found on the mailing list I have managed to get as far as locating the points of interest with find maxima, then add these to the ROI manager.

for(i=0;i<nSlices();i++){
setSlice(i+1);
run("Find Maxima...", "noise=45 output=[Point Selection] exclude light");
run("ROI Manager...");
roiManager("Add");
}
run("Set Measurements...", "  centroid display redirect=None decimal=3");
roiManager("Deselect");
roiManager("Measure");

This works sufficiently well that only the two points of interest are selected and the results window is populated with a list of the coordinate locations of the points, two results per slice.

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


Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Measuring between point selections in a stack

edsimmons
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