Re: Automatically measure width
Posted by Andrew Sanchez on Jan 08, 2016; 5:26am
URL: http://imagej.273.s1.nabble.com/Automatically-measure-width-tp5014170p5015343.html
Thank you Jens.
another question.
Is there a way to ensure that I will get exactly two results for xmax, indicating exactly two results for the edges of the line I am trying to measure?
I have tried adjusting the tolerance (currently 900) and line width in makeLine (currently 20). To be honest, I’m not really sure what tolerance does.
You will see that by running this macro:
fileName = File.nameWithoutExtension;
run("Minimum...", "radius=2");
run("RGB Stack");
run("Z Project...", "projection=[Sum Slices]");
run("Find Edges");
w=getWidth();
h=getHeight();
findEdgeA = (h/2.2);
findEdgeB = (h/2.45);
// Measurement 1
makeLine((w/1.7), findEdgeA, (w/1.7), findEdgeB, 20);
tolerance = 900;
profile = getProfile();
maxLocs = Array.findMaxima(profile, tolerance);
Array.sort(maxLocs);
for (jj= 0; jj < maxLocs.length; jj++){
setResult("filename", jj, fileName);
setResult("xmax", jj, maxLocs[jj]);
if (jj>0)
setResult("delta_xmax", jj, (maxLocs[jj]-maxLocs[jj-1]));
}
updateResults();
With this image open: andrewsanchez.github.io/vlcsnap-2015-10-15-19h01m10s675.png
I get only one result for xmax.
If you run it with this image: andrewsanchez.github.io/vlcsnap-2015-10-15-18h59m09s003.png
you get the correct behavior - two results for xmax and delta_max, which is the difference between the two results for xmax.
Is this a problem I need to address with more ways of processing the image besides the current run("Minimum...", "radius=2"); ?
Thank you,
Andrew