|
Hello,
I'm still working on fiber caracterization and to do so scan along the
fibers and do different measurements, I started to do sliding FFT analysis
and now I want to automate the radius of curvature measurement...
To do so I took advantage of a bit of code provided by Wayne, thus I can
produce along a segment an array of ROI's.
Then "cycling" through the ROI manager I can measure whatever...thus this
simple code might be interesting for other people.
Here, my code should generate evenly spaced point selections along a
segment, those selections are added to the ROI manager.
Next I select consecutive triplet of points and apply "fit circle"...
I came about two problems, when the points are colinear, the macro stops as
no measurement can be performed. Next, I'm able to select 3 points but
nevertheless, the ROI manager specifies "More then one ROI ..." if I press
"OK" the macro continues happily...
Here the code :
// Generate an array of selections along a line.
setTool("polyline");
waitForUser("Draw your line selection");
inc = 30;
run("Fit Spline", "straighten");
wait(2000);
getSelectionCoordinates(x, y);
for (i=0; i<x.length; i+=inc) {
makePoint(x[i]-inc, y[i]-inc);
run("Add to Manager");
}
// cycle trough ROIs, select 3 points and fit circle to output radius of
curvature.
myID = getImageID();
n = roiManager("count");
for (j=0; j<n; j++) {
roiManager("Select", j);
setKeyDown("shift");
roiManager("Select", j+1);
setKeyDown("shift");
roiManager("Select", j+2);
roiManager("Combine");
wait(2000);
run("Fit Circle");
run("Set Measurements...", " centroid bounding redirect=None decimal=3");
run("Measure");
roiManager("Select", j);
//roiManager("Delete");
run("Select None");
selectImage(myID);
}
Note, the code is not cleaned up yet.
By the way, I tested different plugins in order to describe my fiber like
MonogenicJ and OrientationJ, i tried aswell "Analyse curvature" and most of
the time I'm not happy with the output as I need numbers to perform further
statistics and compare lots of fibers...
All suggestions are welcome and I'm convinced this questions are of
interest for others than myself,
Thank you,
Fabrice.
|