Posted by
Seth Pappas on
URL: http://imagej.273.s1.nabble.com/Adding-a-measurement-type-tp5005620p5005640.html
Wayne,
People using Image J for live video display and capture will want to know that the IRLabs Ge pixel TRIWAVE USB2.0 camera has been tested and works flawlessly with the plugin. Would you consider adding it to the camera list in your description of the plugin?
Many thanks,
Seth Pappas
-----Original Message-----
From: Rasband, Wayne (NIH/NIMH) [E] (NIH/NIMH) [E] <
[hidden email]>
To: IMAGEJ <
[hidden email]>
Sent: Wed, Nov 20, 2013 11:41 pm
Subject: Re: Adding a measurement type
On Nov 20, 2013, at 10:00 AM, Grant Harris wrote:
> I'd like to add a measurement for circular/directional statistics for
calculating the average orientation of an area/ROI.
> I'd like to do this so that I can utilize the functionality of the RoiManager
and the ResultsTable, e.g. select a number of ROIs, do the measurement, and have
the results in a table. Does anyone have an idea on how to do this?
Have you considered using the "Fit ellipse" measurement option to get ROI
orientation? It adds "Major", "Minor" and "Angle" columns to the Results table.
Here is an example macro that draws the ellipse major axis on each particle in
the Blobs sample image:
saveSettings;
open("
http://imagej.nih.gov/ij/images/blobs.gif");
setAutoThreshold("Default");
run("Set Measurements...", " centroid fit");
run("Analyze Particles...", "exclude clear");
resetThreshold();
setColor("red");
setLineWidth(2);
for (i=0; i<nResults; i++) {
xc = getResult("X", i);
yc = getResult("Y", i);
major = getResult("Major", i);
angle = getResult("Angle", i);
dx = major*cos(angle/180 * PI)/2;
dy = -major * sin(angle/180 * PI)/2;
x1 = xc - dx;
x2 = xc + dx;
y1 = yc - dy;
y2 = yc + dy;
Overlay.drawLine(x1, y1, x2, y2);
}
Overlay.show;
restoreSettings;
And here is a JavaScript version:
imp = IJ.openImage("
http://imagej.nih.gov/ij/images/blobs.gif");
Analyzer.setMeasurement(Measurements.CENTROID, true);
Analyzer.setMeasurement(Measurements.ELLIPSE, true);
IJ.setAutoThreshold(imp, "Default");
IJ.run(imp, "Analyze Particles...", "exclude clear");
IJ.resetThreshold(imp);
rt = Analyzer.getResultsTable();
overlay = new Overlay();
for (i=0; i<rt.getCounter(); i++) {
xc = rt.getValue("X", i);
yc = rt.getValue("Y", i);
major = rt.getValue("Major", i);
angle = rt.getValue("Angle", i);
dx = major*Math.cos(angle/180 * Math.PI)/2;
dy = -major * Math.sin(angle/180 * Math.PI)/2;
x1 = xc - dx;
x2 = xc + dx;
y1 = yc - dy;
y2 = yc + dy;
line = new Line(x1, y1, x2, y2);
line.setStrokeColor(Color.red);
line.setStrokeWidth(2);
overlay.add(line);
}
imp.setOverlay(overlay);
imp.show();
[cid:
[hidden email]]
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html