Posted by
Ludgate, David on
Aug 10, 2005; 7:14pm
URL: http://imagej.273.s1.nabble.com/Get-the-Measurement-Result-through-Java-code-tp3705058p3705059.html
This does what you want, recording area and centroid coordinates, and
showing no output, on a blank image (default ImagePlus). Change whatever
you require.
ImagePlus img = new ImagePlus(); //image you want to process
min = 0; //minimum particle size
max = 99999; //max particle size
options = ParticleAnalyzer.SHOW_NONE; //add together all the options you
want
Measurements = Measurements.AREA + Measurements.Centroid; //add together
all the measurements you want
ResultsTable rt = new ResultsTable();//if you define a resultsTable
yourself, you can explicitly call it later
ParticleAnalyzer pa = new ParticleAnalyzer(measurements, options,
rt,min,max);
Pa.analyze(img);
//now all your data is in rt. Use rt.getValue("Area",i); to get areas
out.
Cheers,
dave
-----Original Message-----
From: ImageJ Interest Group [mailto:
[hidden email]] On Behalf Of
Cheok Yan Cheng
Sent: Tuesday, August 09, 2005 10:41 PM
To:
[hidden email]
Subject: Get the Measurement Result through Java code.
Hi, in my java applications, I had made intensive use
on the ImageJ function. However, there is one thing
which stop me from progressing on. May I know how I
can get the measurement result through java code?
For example:
import ij.*;
import ij.process.*;
public class test
{
public static void main(String[] args)
{
IJ.open("C:\\Documents and
Settings\\yccheok\\Desktop\\test.bmp");
ImagePlus imagePlus =
WindowManager.getCurrentImage();
System.out.println("ImagePlus
width="+imagePlus.getWidth());
IJ.run("8-bit");
IJ.run("Threshold");
IJ.run("Set Measurements...", "area bounding display
redirect=None decimal=3");
IJ.run("Measure");
IJ.run("Analyze Particles...", "minimum=1
maximum=999999 bins=20 show=Nothing display");
// How can I get the particles analyze result?????
// ???
// double[] result = IJ.getMeasurementResult();???
}
}
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com