http://imagej.273.s1.nabble.com/Get-ROI-statistics-in-Javascript-tp5018887p5018893.html
Unfortunately it does not make a difference. getAllStatistics is a slower
correctly. Both fail to return the mean value along the segmented line ROI.
> Hi Christophe,
> The command you are using is different from what I am using. I am using:
>
> var stats = imp.get*All*Statistics();
>
> And you are using:
>
> var stat = imp.getStatistics();
>
> I hope this helps,
> Avital
>
>
>
>
> On Wed, Jun 14, 2017 at 4:15 PM, Christophe Leterrier <
>
[hidden email]> wrote:
>
>> Hi Avita,
>>
>> Thank you for the pointer. It works well with a rectangular ROI (I get
>> the mean intensity inside the ROI). However, using this with a segmented
>> line ROI returns the mean intensity of the whole image, not the mean
>> intensity value for the segmented line ROI (given manually by using
>> "Measure" with the ROI activated). What am I doing wrong here?
>>
>> - open a sample image.
>> - draw a segmented line ROi on it, store it in the ROI manager.
>> - run this script:
>>
>> importClass(Packages.ij.IJ);
>> importClass(Packages.ij.plugin.frame.RoiManager);
>> importClass(Packages.ij.gui.Roi);
>>
>> var imp = IJ.getImage();
>> var rm = RoiManager.getInstance();
>>
>> var roi = rm.getRoi(0);
>> imp.setRoi(roi, false);
>> var stat = imp.getStatistics();
>>
>> var mean = stat.mean;
>> IJ.log(mean);
>>
>> the value returned is the mean intensity of the whole image, not of the
>> segmented line ROI.
>>
>>
>>
>> Christophe
>>
>> On Wed, Jun 14, 2017 at 1:41 PM, Avital Steinberg <
>>
[hidden email]> wrote:
>>
>>> Hi Christophe,
>>> You can get the Roi statistics like this:
>>>
>>> imp.setRoi(roi, false);
>>> var stats = imp.getAllStatistics();
>>> var median = stats.median;
>>>
>>> The stats objects is an ImageStatistics object, so you can see which
>>> fields
>>> it has here:
>>>
>>>
https://imagej.nih.gov/ij/developer/api/ij/process/ImageStatistics.html>>>
>>> Good luck,
>>> Avital
>>>
>>> On Wed, Jun 14, 2017 at 12:24 PM, Christophe Leterrier <
>>>
[hidden email]> wrote:
>>>
>>> > Dear ImageJers,
>>> >
>>> > I'm trying to write a javascript snippet that retrieves a ROI from the
>>> ROI
>>> > manager, and returns the mean intensity but I can't seem to find out
>>> how to
>>> > do it.
>>> >
>>> > Here am I so far:
>>> >
>>> > - open a sample image
>>> > - draw a ROi on it, store it in the ROI manager
>>> > - run this script:
>>> >
>>> > importClass(Packages.ij.IJ);
>>> > importClass(Packages.ij.plugin.frame.RoiManager);
>>> > importClass(Packages.ij.gui.Roi);
>>> >
>>> > var imp = IJ.getImage();
>>> > var rm = RoiManager.getInstance();
>>> >
>>> > var roi = rm.getRoi(0);
>>> > roi.setImage(imp);
>>> > var stat = roi.getStatistics();
>>> > IJ.log(stat.mean);
>>> >
>>> > the "mean" property of the ImageStatistic returned by getStatistics()
>>> has a
>>> > value of NaN. How come? How to access the roi statistics in a purely
>>> > programmatic manner (ie without displaying stuff)?
>>> >
>>> > Thanks for your help,
>>> >
>>> > Christophe
>>> >
>>> > --
>>> > ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>>> >
>>>
>>> --
>>> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>>>
>>
>>
>