Running IJ.Run("Set Measurements...") and getting the outputs using Java codes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Running IJ.Run("Set Measurements...") and getting the outputs using Java codes

luckyluke
Ho ImageJ users,

I am running the below coed fro getting some features from an image but I want to get the features for my codes.

IJ.run("Set Measurements...", "area mean min median area_fraction redirect=IMD002_lesion.bmp decimal=3");


Can someone point me how to get the properties such as  area, mean, min, median, area_fraction

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Running IJ.Run("Set Measurements...") and getting the outputs using Java codes

Avital Steinberg
Hi Luke,
ImageJ's macro API has the functions getStatistics and getRawStatistics:

*getStatistics(area, mean, min, max, std, histogram)*
Returns the area, average pixel value, minimum pixel value, maximum pixel
value, standard deviation of the pixel values and histogram of the active
image or selection. The histogram is returned as a 256 element array. For
8-bit and RGB images, the histogram bin width is one. For 16-bit and 32-bit
images, the bin width is (*max*-*min*)/256. For examples, refer to the
ShowStatistics <http://rsb.info.nih.gov/ij/macros/ShowStatistics.txt> macro
set. Note that trailing arguments can be omitted. For example, you can use
*getStatistics(area)*, *getStatistics(area, mean)* or *getStatistics(area,
mean, min, max)*. See also: getRawStatistics
<http://rsb.info.nih.gov/ij/developer/macro/functions.html#getRawStatistics>
and List.setMeasurements
<http://rsb.info.nih.gov/ij/developer/macro/functions.html#List.setMeasurements>

If you're writing a Java plugin, it's possible to run some macro code using
the following method:

http://osdir.com/ml/java.imagej/2004-11/msg00023.html

The macro can get input only as a string, and this string will be recieved
by the macro using the following command in the first line of the macro:

"macroInputArg = getArgument();"+

The macro can only return a string, so in Java, this string would have to
be converted back to the right type, such as double or integer.


Good luck,
Avital



On Sat, Nov 15, 2014 at 11:16 AM, luckyluke <
[hidden email]> wrote:

> Ho ImageJ users,
>
> I am running the below coed fro getting some features from an image but I
> want to get the features for my codes.
>
> IJ.run("Set Measurements...", "area mean min median area_fraction
> redirect=IMD002_lesion.bmp decimal=3");
>
>
> Can someone point me how to get the properties such as  area, mean, min,
> median, area_fraction
>
> Thanks
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Running-IJ-Run-Set-Measurements-and-getting-the-outputs-using-Java-codes-tp5010456.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Running IJ.Run("Set Measurements...") and getting the outputs using Java codes

Gabriel Landini
On Saturday 15 Nov 2014 11:43:49 Avital Steinberg wrote:
> ImageJ's macro API has the functions getStatistics and getRawStatistics:
>
> *getStatistics(area, mean, min, max, std, histogram)*

That is not what is being asked.

To get the descriptors that you chose in SetMeasurements, you need to then set
a threshold (so the regions are shown in red and then use the Analyze
Particles command.

Cheers

Gabriel

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Running IJ.Run("Set Measurements...") and getting the outputs using Java codes

luckyluke
Hi,

I have done the threshoding and analyse particles previously ..now then i execute set measures to get it the descriptive from my ROI..but still I don't have any idea how to get all those marks in set meaures windows with my java application?

this is the coed i use

====
IJ.run(imp, "8-bit", "");
IJ.run(imp, "Make Binary", "");
IJ.run(imp, "Analyze Particles...", "size=1-Infinity show=Outlines clear add");
rm.select(0);
IJ.run("Set Measurements...", "area mean min median area_fraction redirect=IMD002.bmp decimal=3");
rm.select(0);
rm.runCommand("Measure");
====

but how to get the measures in set measure windows?
Reply | Threaded
Open this post in threaded view
|

Re: Running IJ.Run("Set Measurements...") and getting the outputs using Java codes

Michael Schmid
Hi Luckluke,

your question is not really clear. Is it the "Set Measurements" options
that you ask about, for use in a Java plugin that you write?

You have two Choices:
(1) use the Macro recorder in 'Plugin' Mode

(2) You can use the following call to create a ParticleAnalyzer with the
options that you want

ParticleAnalyzer(int options, int measurements, ResultsTable rt, double
minSize, double maxSize, double minCirc, double maxCirc)

Here 'options' are the ParticleAnalyzer options, e.g.
ParticleAnalyzer.SHOW_OUTLINES (add them if you have more than one), and
'measurements' are the options of ij.measure.Measurements, like
AREA+MEAN.MEDIAN (add 'implements Measurements in your plugin).

For the 'redirection' image, use
  ij.plugin.filter.Analyzer.setRedirectImage(ImagePlus imp);


Or do you want to get the results of the Measurements? They are in the
ResultsTable; here are a few useful code snippets:

  ResultsTable rt = Analyzer.getResultsTable();
  int counter = rt.getCounter();  //number of results
  if (counter==0)
    //no results, handle that error here
  int col = rt.getColumnIndex("Area");
  for (int row=0; row<counter, row++)
    double value = rt.getValueAsDouble(col, row); //all the Area values

Michael
____________________________________________________________


On Sun, November 16, 2014 08:54, luckyluke wrote:

> Hi,
>
> I have done the threshoding and analyse particles previously ..now then i
> execute set measures to get it the descriptive from my ROI..but still I
> don't have any idea how to get all those marks in set meaures windows with
> my java application?
>
> this is the coed i use
>
> ====
> IJ.run(imp, "8-bit", "");
> IJ.run(imp, "Make Binary", "");
> IJ.run(imp, "Analyze Particles...", "size=1-Infinity show=Outlines clear
> add");
> rm.select(0);
> IJ.run("Set Measurements...", "area mean min median area_fraction
> redirect=IMD002.bmp decimal=3");
> rm.select(0);
> rm.runCommand("Measure");
> ====
>
> but how to get the measures in set measure windows?
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Running IJ.Run("Set Measurements...") and getting the outputs using Java codes

luckyluke
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Running IJ.Run("Set Measurements...") and getting the outputs using Java codes

luckyluke
Hi Michale,
Thanks for your help. 
Actually in ImageJ aim doing a masking using particle analyzer then I wanna get measure from the are of my image using the masking obtained by particle analyzer.so I first do a particle analyzer on my black and white mask and then send it to ROI manger..then I will do measures in ROI manger to get measurement set in set measurements on my main image.
I am interested to do it by plugin recorder but when I run IJ.run("Set Measurements...", "area mean min median area_fraction redirect=IMD002.bmp decimal=3"); I am not sure how to get results?
===IJ.run(imp, "8-bit", ""); 
> IJ.run(imp, "Make Binary", ""); 
> IJ.run(imp, "Analyze Particles...", "size=1-Infinity show=Outlines clear 
> add"); 
> rm.select(0); 
> IJ.run("Set Measurements...", "area mean min median area_fraction 
> redirect=IMD002.bmp decimal=3"); 
> rm.select(0); 
> rm.runCommand("Measure"); 
===
Thanks for your suggestion for codes, but I do meaures on another image using ROI not in options in particle analyzer..
Thanks if you have any suggestion..
Regards