Hi everyone,
I am trying to get a few measurements programmatically within a plugin. Ideally I would like that to be invisible to the user (i.e. do displaying a result table). So I don't want to call IJ.run("Set Measurements") and IJ.run("Measure"). Currently my code looks like: ResultsTable rt = new ResultsTable(); // imB is an ImagePlus Analyzer ana = new Analyzer(imB, CENTROID, rt); ana.setMeasurement(AREA, true); ana.setMeasurement(ELLIPSE, true); ana.measure(); rt = ana.getResultsTable(); rt.show("Results"); // just to check I have (at least) two problems with that: 1/ Is it the correct way to select several measurements? Can I somewhere give a string with all measurements I what like in the IJ.run case? Here I am expecting to get CENTROID, AREA, and ELLIPSE. 2/ measure() is described as public void measure() in the API but the compilation gives: src/imagej/plugins/Threshold_Stack.java:92: measure() is not public in ij.plugin.filter.Analyzer; cannot be accessed from outside package and indeed in the source it is only void measure(). In that case, how do I trigger the collection of the measurements I set before? Silly question but I could not figure it out. Thanks in advance. Sincerely, JiHO --- http://maururu.net PS: More generally, I find it very easy to chain up ImageJ functionality in macros or macro like plugins (i.e. which call IJ.run("something")) but I am really struggling to convert those to the less GUI oriented way of calling the plugins/classes directly, as for the case above. My only source of information is currently the API and, while it gives all the possibilites for each class, it does not really orient me towards how those should be used. Is there some other resource tat would complement the API? Something based on commented examples maybe, showing how to use each each plugin for example. I've read "Writing ImageJ plugins" and wandered through the wiki but this did not really help. I am curious to know how the numerous plugins developer work when they face the need to introduce new functionality from ImageJ's API. Thanks again. |
Sorry, a typing mistake makes my first sentence ambiguous.
Instead of: On 2009-June-25 , at 18:02 , JiHO wrote: > Ideally I would like that to be invisible to the user (i.e. do > displaying a result table) I wanted to say Ideally I would like that to be invisible to the user (i.e. NOT displaying a result table) |
In reply to this post by JiHO-2
On Jun 25, 2009, at 6:02 PM, JiHO wrote:
> Hi everyone, > > I am trying to get a few measurements programmatically within a > plugin. Ideally I would like that to be invisible to the user (i.e. do > displaying a result table). So I don't want to call IJ.run("Set > Measurements") and IJ.run("Measure"). Currently my code looks like: Use the ImagePlus.getStatistics() method. Here is an example: public class My_Plugin implements PlugIn, Measurements { public void run(String arg) { ImagePlus imp = IJ.getImage(); ImageStatistics stats = imp.getStatistics(AREA+CENTROID+ELLIPSE); IJ.log("Area: "+stats.area); IJ.log("xCentroid: "+stats.xCentroid); IJ.log("yCentroid: "+stats.yCentroid); IJ.log("Major: "+stats.major); IJ.log("Minor: "+stats.minor); IJ.log("Angle: "+stats.angle); } } -wayne > > ResultsTable rt = new ResultsTable(); > // imB is an ImagePlus > Analyzer ana = new Analyzer(imB, CENTROID, rt); > ana.setMeasurement(AREA, true); > ana.setMeasurement(ELLIPSE, true); > ana.measure(); > rt = ana.getResultsTable(); > rt.show("Results"); // just to check > > I have (at least) two problems with that: > > 1/ Is it the correct way to select several measurements? Can I > somewhere give a string with all measurements I what like in the > IJ.run case? Here I am expecting to get CENTROID, AREA, and ELLIPSE. > > 2/ measure() is described as public void measure() in the API but the > compilation gives: > src/imagej/plugins/Threshold_Stack.java:92: measure() is not public > in ij.plugin.filter.Analyzer; cannot be accessed from outside package > and indeed in the source it is only void measure(). In that case, how > do I trigger the collection of the measurements I set before? Silly > question but I could not figure it out. > > Thanks in advance. Sincerely, > > JiHO > --- > http://maururu.net > > PS: More generally, I find it very easy to chain up ImageJ > functionality in macros or macro like plugins (i.e. which call > IJ.run("something")) but I am really struggling to convert those to > the less GUI oriented way of calling the plugins/classes directly, as > for the case above. My only source of information is currently the API > and, while it gives all the possibilites for each class, it does not > really orient me towards how those should be used. Is there some other > resource tat would complement the API? Something based on commented > examples maybe, showing how to use each each plugin for example. > I've read "Writing ImageJ plugins" and wandered through the wiki but > this did not really help. I am curious to know how the numerous > plugins developer work when they face the need to introduce new > functionality from ImageJ's API. > > Thanks again. > |
Free forum by Nabble | Edit this page |