http://imagej.273.s1.nabble.com/Adding-a-measurement-type-tp5005620p5005679.html
performed when the ParticleAnalyzer is used.
> It is easy to add custom measurements to the Results table. This example macro opens the Blobs sample image, creates a selection, measures the area, mean, centroid and perimeter, and then calculates the perimeter mean and adds it to the same row of the Results table as "PMean". This macro has a keyboard shortcut so you can run it by typing "1".
>
> macro "Measure Boundary Mean [1]" {
> saveSettings;
> run("Blobs (25K)");
> setAutoThreshold("Default");
> doWand(114, 82);
> run("Interpolate", "interval=1 smooth");
> resetThreshold();
> run("To Selection");
> run("Set Measurements...", "area mean centroid perimeter");
> run("Measure");
> getSelectionCoordinates(x, y);
> n = x.length;
> sum = 0;
> for (i=0; i<n; i++)
> sum += getPixel(x[i], y[i]);
> mean = sum/n;
> setResult("PMean", nResults-1, mean);
> restoreSettings;
> }
>
> Here is a JavaScript version:
>
> imp = IJ.openImage("
http://imagej.nih.gov/ij/images/blobs.gif");
> IJ.setAutoThreshold(imp, "Default");
> IJ.doWand(imp, 128, 83, 0, "Legacy");
> //imp.show();
> IJ.run(imp, "Interpolate", "interval=1 smooth");
> IJ.resetThreshold(imp);
> IJ.run(imp, "To Selection", "");
> IJ.run("Set Measurements...", "area mean centroid perimeter");
> roi = imp.getRoi();
> p = roi.getPolygon();
> n = p.npoints;
> sum = 0;
> ip = imp.getProcessor();
> for (i=0; i<n; i++)
> sum += ip.getPixel(p.xpoints[i], p.ypoints[i]);
> mean = sum/n;
> analyzer = new Analyzer(imp);
> analyzer.measure();
> rt = Analyzer.getResultsTable();
> rt.addValue("PMean", mean)
> rt.show("Results");
>
>
> On Nov 23, 2013, at 11:59 AM, Peter Haub wrote:
>
>> Adrians idea is very nice.
>>
>> Just to give an input (no a solution) to this:
>>
>> I could imagine the possibility to specify a (set of) 'user defined measurement macro' or a 'user defined measurement plugin'.
>> This 'user defined measurements' could be selected in the measurement dialog, e.g. as UDMM_xx or UDMP_xx where xx is a number 00 .. 99.
>>
>> The modification in ImageJ should be not to complicated and the definition of an appropriate interface, return value and naming scheme of the macro/plugin not to complex.
>>
>> Peter
>>
>> On 22.11.2013 18:47, Adrian Daerr wrote:
>>> Hello,
>>>
>>> On 11/20/2013 04:00 PM, 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?
>>> I have no answer to your question, but merely want to highlight the part of it which has not been discussed. So far contributions focussed directly on the problem at hand of measuring orientations, but I would find really interesting if there were also ideas on how to allow adding custom measurements in general. I have wanted to do that on several occasions (two examples: to measure fourier coefficients on the rim of circular selections; to measure the mean intensity on the boundary of a ROI). If there was a way to easily add to the measurement dialog a function/plugin(via a new MeasurementFilter interface?)/macro that takes an image+(roi/mask) as input and returns one or more double values, one could calculate any quantity on selections with minimal coding, and benefit from ImageJ's measurement functionalities mentioned by GH.
>>>
>>> I have no idea if this is easy to implement, but it might be a feature request worth considering for IJ1 or IJ2.
>>>
>>> cheers,
>>> Adrian
>>> (frequent user of the Process->Math->Macro..., which by allowing for arbitrary functions has sharply reduced the need for one-shot plugins iterating over all pixels and images)
>>>
>>> --
>>> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>>>
>>>
>> --
>> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html